标签:min end prefix record efi nil dmi edit pre
classs Admin < activeRecord::Base delegate :firstname, :to => :user # 等价于 # firstname => user.firstname # delegate :firstname, :to => :user, :prefix => true # 等价于 # user_firstname => user.firstname # delegate :firstname, :to => :user, :allow_nil => true, :prefix => true # 等价于 # user_firstname => user.try(:firstname) # delegate :name, :to => "user.try(:editor)", :prefix => :editor # 等价于 # editor_name => user.try(:editor).name #注意空异常 # delegate :name, :to => "user.try(:editor)", :prefix => :editor, :allow_nil => true # 等价于 # editor_name => user.try(:editor).try(:name) end
标签:min end prefix record efi nil dmi edit pre
原文地址:https://www.cnblogs.com/hello-ruby/p/13195643.html