Forum: Ruby on Rails defining a global scope on a model

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
20b1836f8acccd107b4992a1a45a14bd?d=identicon&s=25 chrisfarms (Guest)
on 2007-04-05 16:59
(Received via mailing list)

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] }

class SomeSpecialModel < SomeModel
  set_table_name 'some_models'
  scoped_methods << {
    :find => {:conditions => ['is_special = ?', true] }

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 :)

This topic is locked and can not be replied to.