Hey! Maybe I am getting the idea of a subclass wrong, but I have a Person model and it has an attrib called "age" so
Person.first.age #=> '20'
Now I want to have a model that's basically persons 55 or older so I know I can have a class like this: class Senior < Person end
But how can I "pre-filter" the Senior class so that every object belonging to that class has age >= 55?
Senior.first.age #=> 56
UPDATE1: So say I have Company has_many people, and Person belongs_to Company, so Company.first.people #=> ["Jack", "Kate"]
If Jack's age is > 55, will it work then: Company.first.seniors #=> "jack"
Or
Company.first.people.senior(s) #=> "jack"?
I know that named_scope might be what I want, but I also notice that named_scope seems to be a method on the Class variable Person. Not its instances, which does make sense to me. -- So if I were to devise such a convenience filter for a collection of activerecord models (objects of the same class), how do I go about it? I am guessing I'd have to use a "detect" for such an array, but where will this go inside the Model's definition?
Update 2 I am quite sure I haven't been clear, so example Want: first company's 55 or older people Company.first.people.detect{|p| p.age > 54}
I know this isn't very long, but my conditions will go farther than just > 54 and it becomes clumsy to do this detect each time.
Thanks!