vendredi 15 mai 2015

Where is Person and not Person::Single

Lets say I have three Classes

Person

Person::Single < Person

Person::Married < Person

Lets say I have two Persons that are Single => Person::Single

Then i get two Persons when I do:

Person.all.count
=> 2

But my goal is to get only the persons that are type Person and not Person::Single or Person::Married

What I tried is:

Person.where(type: Person.to_s)
=> 2

but this also returns 2 because Person::Single and Person::Married inherit from Person

What can I do instead? Is there for example an way to say that ::Single and ::Married have the same methods from person but are not the same type? Thanks

Aucun commentaire:

Enregistrer un commentaire