# Problems with model inheritance in development

**URL:** <https://www.ruby-forum.com/t/problems-with-model-inheritance-in-development/147211>\
**Category:** Engines\
**Created:** [August 29, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/problems-with-model-inheritance-in-development/147211 "2008-08-29T12:43:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonio\_Tapiador\_de](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a183cd/32.png) [@Antonio\_Tapiador\_de](https://www.ruby-forum.com/u/Antonio_Tapiador_de)\
**Post date:** [August 29, 2008, 12:43pm UTC](https://www.ruby-forum.com/t/problems-with-model-inheritance-in-development/147211/1 "2008-08-29T12:43:50Z")

</div>

Hi!  
I have problems when a model inherits from another ActiveRecord model:

class Space \< ActiveRecord::Base  
end

class Project \< Space  
end

This only happens in development environment. Not in production, neither  
in  
testing. And never in the first request after a server restart, always  
after  
the second request.  
So I belive it has to do with something related with class reloading.

It seems like after the reloading, the “Space” part of the Project class  
is  
missing, like in this error (container\_posts is a method of Space):

NoMethodError (undefined method `container_posts' for #<Project:0xb4a533cc>): /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:256:in`method\_missing’  
/vendor/plugins/cmsplugin/app/controllers/posts\_controller.rb:18:in  
`index’  
[…]

I get other errors related with “stack level too deep”, but I can’t  
reproduce  
them now

---

<div class="post-metadata">

**Author:** ![Antonio\_Tapiador\_de](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a183cd/32.png) [@Antonio\_Tapiador\_de](https://www.ruby-forum.com/u/Antonio_Tapiador_de)\
**Post date:** [September 1, 2008, 12:13pm UTC](https://www.ruby-forum.com/t/problems-with-model-inheritance-in-development/147211/2 "2008-09-01T12:13:51Z")

</div>

El Friday 29 August 2008 12:43:35 Antonio Tapiador del Dujo  
escribió:\> testing. And never in the first request after a server restart, always

> ```
> /vendor/plugins/cmsplugin/app/controllers/posts_controller.rb:18:in
> 
> ```
> 
> `index’  
> […]
> 
> I get other errors related with “stack level too deep”, but I can’t  
> reproduce them now

Here they are. I’ll try to get them a look if I have time…

SystemStackError in PostsController#index

stack level too deep

/usr/lib/ruby/1.8/set.rb:157:in `include?' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:104:in`instance\_method\_already\_implemented?’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/attribute\_methods.rb:82:in  
`define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:71:in`each’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/attribute\_methods.rb:71:in  
`define_attribute_methods' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/attribute_methods.rb:238:in`method\_missing’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active\_record/attribute\_methods.rb:245:in  
`method_missing' /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:2435:in`hash’  
vendor/plugins/cmsplugin/app/controllers/posts\_controller.rb:29:in  
`uniq' vendor/plugins/cmsplugin/app/controllers/posts_controller.rb:29:in`index’

[…]
