【发布时间】:2010-10-01 12:17:07
【问题描述】:
我收到了一个 named_scope 错误,我是否尝试不正确地使用它?
class Owner < ActiveRecord::Base
has_many :dogs
named_scope :is_fit?, :conditions => { :age => 16..40 }
end
class Dog < ActiveRecord::Base
belongs_to :owner
def is_owner_fit?
owner.is_fit?
end
end
undefined method `is_fit?' for #<ActiveRecord::Associations::BelongsToAssociation:0x251807c>
【问题讨论】: