开发者

Difference between these two attr_reader?

class CustomerClass < ActiveRecord
   class << self
     attr_reader :lov
   end
   at开发者_Python百科tr_reader :lov1
end

What is the diffrence between attr_reader lov and lov1 ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜