Forum: Ruby on Rails ActiveRecord models w/ base condition

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Belorion (Guest)
on 2006-01-12 20:35
(Received via mailing list)
Does anyone know how to do the following?  I have 3 different AR classes
that all map to the same table.  The only difference between this AR
classes
is that they should only return record that match a certain condition.

For example, Foo should only return records from table 'list' that
follow
the condition ftype="foo", where as Bar, on the other hand, should only
return records that follow the condition ftype="bar".

I know I can specify conditions and finder_sql with relationships, but I
want to define a base level condition for the model.  Is this possible?
Any
suggestions?

-Matt
Mark Reginald J. (Guest)
on 2006-01-13 01:29
(Received via mailing list)
Belorion wrote:
> want to define a base level condition for the model.  Is this possible?
> Any suggestions?

Single table inheritance will do what you want.  Read about it here:
   http://api.rubyonrails.com/classes/ActiveRecord/Base.html

--
We develop, watch us RoR, in numbers too big to ignore.
Belorion (Guest)
on 2006-01-13 05:46
(Received via mailing list)
On 1/12/06, Mark Reginald J. <removed_email_address@domain.invalid> wrote:
>
> Single table inheritance will do what you want.  Read about it here:
>    http://api.rubyonrails.com/classes/ActiveRecord/Base.html
>

Great, thanks.  I'm not sure why that didn't occur to me in the first
place!

Matt
This topic is locked and can not be replied to.