tags:

views:

33

answers:

1
class CustomerClass < ActiveRecord
   class << self
     attr_reader :lov
   end
   attr_reader :lov1
end

What is the diffrence between attr_reader lov and lov1 ?

+2  A: 

The difference is that :lov will be a class-level accessor, while :lov1 is instance-level.

So, you can only access lov1 from an instance:

customer = CustomerClass.new
lov1 = customer.lov1

While CustomerClass.lov1 wouldn't work, but CustomerClass.lov would.

Jacob Relkin
@Jacob Relkin Can you please explain it with proper example ?
krunal shah
@krunal shah, See my updated answer.
Jacob Relkin