# Problem with inheritance and "self"

**URL:** <https://www.ruby-forum.com/t/problem-with-inheritance-and-self/84691>\
**Category:** Ruby\
**Created:** [February 7, 2007, 1:36am UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-self/84691 "2007-02-07T01:36:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giles\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@Giles\_B](https://www.ruby-forum.com/u/Giles_B)\
**Post date:** [February 7, 2007, 1:36am UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-self/84691/1 "2007-02-07T01:36:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Giles\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@Giles\_B](https://www.ruby-forum.com/u/Giles_B)\
**Post date:** [February 7, 2007, 5:28am UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-self/84691/2 "2007-02-07T05:28:47Z")

</div>

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