ruby subclass filter

Posted by Nik on Stack Overflow See other posts from Stack Overflow or by Nik
Published on 2010-03-29T09:43:41Z Indexed on 2010/03/29 10:03 UTC
Read the original article Hit count: 192

Filed under:
|

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

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby