# Defining a global scope on a model

**URL:** <https://www.ruby-forum.com/t/defining-a-global-scope-on-a-model/91200>\
**Category:** Rails\
**Created:** [April 5, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/defining-a-global-scope-on-a-model/91200 "2007-04-05T16:59:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisfarms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@chrisfarms](https://www.ruby-forum.com/u/chrisfarms)\
**Post date:** [April 5, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/defining-a-global-scope-on-a-model/91200/1 "2007-04-05T16:59:00Z")

</div>

Help!

I’ve got a table sharing situation where Single Table Inheritance is  
not viable.

I would like to be able to define a “scope” that is applied whenever I  
am using that model to allow me to construct my relationships.

so far I have done this:

class SomeModel \< ActiveRecord::Base  
scoped\_methods \<\< {  
:find =\> {:conditions =\> [‘is\_special = ?’, false] }  
}  
end

class SomeSpecialModel \< SomeModel  
set\_table\_name ‘some\_models’  
scoped\_methods \<\< {  
:find =\> {:conditions =\> [‘is\_special = ?’, true] }  
}  
end

This actually satisfies my requirements… but I’m not happy about  
using the undocumented array of “scoped\_methods” for my purpose…

Is there a more Railsy way of achieving this goal?

Any ideas welcome…except STI 🙂

farms.
