做了一个命名范围:
class Activity
scope :active, where("active = ?", true)
has_many :attachments, :as => :attachable
accepts_nested_attributes_for :attachments
end
a = Activity.active
工作正常,但关联a.attachments
不行(NoMethodError:未定义的方法“附件”)
做了一个命名范围:
class Activity
scope :active, where("active = ?", true)
has_many :attachments, :as => :attachable
accepts_nested_attributes_for :attachments
end
a = Activity.active
工作正常,但关联a.attachments
不行(NoMethodError:未定义的方法“附件”)