krunal shah
krunal shah

Reputation: 16339

Difference between these two attr_reader?

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

What is the diffrence between attr_reader lov and lov1 ?

Upvotes: 1

Views: 178

Answers (1)

Jacob Relkin
Jacob Relkin

Reputation: 163288

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.

Upvotes: 2

Related Questions