Problem with inheritance and "self"

I have three classes.

AbstractThing
BlueThing
RedThing

inside AbstractThing:

def self.get
self.find(:first)
end

(yup, it’s a Rails app)

I want the DB to only have tables for blue_things and red_things –
but currently, this method gives me a search for abstract_things. The
reason is, the method dispatch pops up to super, finds the method, and
away we go.

How do I redefine this method so I only have to define it inside
AbstractThing, yet when I do, the method dispatch works in such a way
that BlueThing will look for blue_things in the DB, but do it using
AbstractThing’s #get() method? In other words – how do I get the
method to act not from within the superclass which defines it, but the
specific class which uses it?

Just want to say, this turned out to be a Rails problem, not a Ruby
thing at all.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs