Important practical Points to remember from project ::

 Important practical  Points to remember from project :: 


1. how to write the scope ::

scope :newest_first, -> { order(created_at: :desc) }

scope :by_role, -> (role) { includes(:role).where(roles: {name: role}) }

scope :employees, -> { includes(:role).where(roles: {name: "Employee"}) }

2. what is attr_accessor in ror ::

In Ruby, object methods are public by default, while data is private. To access and modify data, we use the attr_reader and attr_writer . attr_accessor is a shortcut method when you need both attr_reader and attr_writer .

3. what is attr_accessor methods ::

Link ::   https://www.rubyinrails.com/2014/03/17/what-is-attr_accessor-in-rails/

getter method ::  it is used to retrieve value of the attribute

setter method ::   it is used to set value to the attribute

4. what is self.abstract_class = true is rails :: 

........................................................................

5. there are four methods in the application every model ::

import , export , csv, sample_to_csv, update custom id 

........................................................................



Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5