Active Record Inheritance with out using type_id

A

Austin Fagan

Hi,

I am writing a script that queries a database for records with either
the value '333' or '444' in a field called pin_id in a table called pop.
Currently I have created a model called GoodPop using set_table_name
:pop
I have overrided the first, last and all methods to return only those
records with a pin_id of either '333' or '444'.

This doesnt feel right. I was thinking of using the inheritance_column
to change the type to the pin_id column but then I would need to call
the model name to either 333 or 444- is this right?

Can anyone offer any suggestions?

Thanks
MM
 
B

Brian Candler

Austin Fagan wrote:0
I am writing a script that queries a database for records with either
the value '333' or '444' in a field called pin_id in a table called pop.
Currently I have created a model called GoodPop using set_table_name
:pop
I have overrided the first, last and all methods to return only those
records with a pin_id of either '333' or '444'.

Don't Do That.

Look up the AR documentation for named scopes and anonymous scopes.
 
A

Austin Fagan

Brian said:
Austin Fagan wrote:0

Don't Do That.

Look up the AR documentation for named scopes and anonymous scopes.

Thanks Brian, using named_scopes!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top