I am getting a named_scope error, am i trying to use it incorrectly?
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>
First of all, by conventions in Ruby, methods ending with an interrogation mark should return either true or false. Your named_scope will return owners that are fit, and not test for their fitness… I would write something like: