# ActiveRecord models w/ base condition

**URL:** <https://www.ruby-forum.com/t/activerecord-models-w-base-condition/95092>\
**Category:** Rails\
**Created:** [January 12, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/activerecord-models-w-base-condition/95092 "2006-01-12T19:35:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 12, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/activerecord-models-w-base-condition/95092/1 "2006-01-12T19:35:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 13, 2006, 12:29am UTC](https://www.ruby-forum.com/t/activerecord-models-w-base-condition/95092/2 "2006-01-13T00:29:51Z")

</div>

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:  
[Peak Obsession](http://api.rubyonrails.com/classes/ActiveRecord/Base.html)

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 13, 2006, 4:46am UTC](https://www.ruby-forum.com/t/activerecord-models-w-base-condition/95092/3 "2006-01-13T04:46:12Z")

</div>

On 1/12/06, Mark Reginald J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Single table inheritance will do what you want. Read about it here:  
> [Peak Obsession](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
