【发布时间】:2009-11-12 10:56:32
【问题描述】:
是否可以在您的 Active Record 模型中使用委托并在其上使用 :if 之类的条件?
class User < ApplicationRecord
delegate :company, :to => :master, :if => :has_master?
belongs_to :master, :class_name => "User"
def has_master?
master.present?
end
end
【问题讨论】:
标签: ruby-on-rails ruby activerecord delegates