Hey! I might have misunderstood the subclass, but I have a Person model and I have an attribute called "age", so
Person.first.age
Now I want to have a model in which people are mostly over 55 years old, so I know that I can have a class: Senior class <Person end
But how can I “pre-filter” the senior class so that every object belonging to this class is age> = 55?
Senior.first.age
Update1: Therefore, say that I have a company, and many people, and Person belongs to the company, therefore Company.first.people # => ["Jack", "Kate"]
If Jack's age is> 55, then he will work then: Company.first.seniors # => "jack"
Or
Company.first.people.s Senior (s) # => "jack"?
, named_scope , , , named_scope Person. , . - , activerecord ( ), ? , "" , ?
2
, ,
: 55
Company.first.people.detect {| | p.age > 54}
, , , > 54, , .
!