# Model inheritance problem

**URL:** <https://www.ruby-forum.com/t/model-inheritance-problem/123022>\
**Category:** Rails\
**Created:** [December 13, 2007, 2:13pm UTC](https://www.ruby-forum.com/t/model-inheritance-problem/123022 "2007-12-13T14:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Oldak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Adam\_Oldak](https://www.ruby-forum.com/u/Adam_Oldak)\
**Post date:** [December 13, 2007, 2:13pm UTC](https://www.ruby-forum.com/t/model-inheritance-problem/123022/1 "2007-12-13T14:13:16Z")

</div>

Hi,

I’ve bumped into the following problem. I have two models, one  
inheriting from another:

* * *

class Message \< ActiveRecord::Base  
…

def reply\_link  
[returns string]  
end

end

* * *

## class SpecificMessage \< Message … end

I use single table inheritance

When I render a view that includes

…  
="#{@message.reply\_link}"  
…

for a SpecificMessage object, it works fine once.  
After that, when I try to render it for any object I get the error:

undefined method `reply\_link’ for #SpecificMessage:0xb6813948

Is it a bug, or is there a mechanism I am not aware of?

Any help appreciated 🙂

Best regards,  
Adam Oldak

---

<div class="post-metadata">

**Author:** ![Adam\_Oldak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Adam\_Oldak](https://www.ruby-forum.com/u/Adam_Oldak)\
**Post date:** [December 13, 2007, 2:30pm UTC](https://www.ruby-forum.com/t/model-inheritance-problem/123022/2 "2007-12-13T14:30:14Z")

</div>

On 13 Dec 2007, at 13:12, Adam Oldak wrote:

> After that, when I try to render it for any object I get the error:
> 
> undefined method `reply\_link’ for #SpecificMessage:0xb6813948

That sounds like a weird Dependencies autoloading problem. There have  
been a few people with those recently. In my experience they often  
boil down to doing require ‘xxx’ when you should be doing  
require\_dependency ‘xxx’ or not requiring it at all.

Fred
