Lessons learnt and Good Practices

There are several practices followed in Rails. Since ruby is the backbone of rails, here are few practices that are recommended: Lets consider a class ABC: class Animal attr_accessor :id, :type def self.mouse(object, a1, a2) puts "#{self}" end def animal puts "I m in animal instance method" yield if block_given? end def id @id.to_i end def initialize(id, type) @id = id @type = type end def update_extra_attrs(a1, a2) puts "#{self.inspect}" end end Execution & Explanation: To change the behaviour of attribute's value, always make use of ruby's getter and setter methods.