# Problem with inheritance and find

**URL:** <https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054>\
**Category:** Rails\
**Created:** [November 11, 2008, 4:41pm UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054 "2008-11-11T16:41:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joserwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@joserwan](https://www.ruby-forum.com/u/joserwan)\
**Post date:** [November 11, 2008, 4:41pm UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054/1 "2008-11-11T16:41:27Z")

</div>

Hi,

I’ve got 3 classes :

class Person \< ActiveRecord:Base  
end

class Man \< Person  
end

class Father \< Man  
end

When I call Man.all, I expect to have men and fathers, but I don’t.  
When I call Person.all, I have people, men and fathers…

Do I have to redefine the find method of the Father’s class ???  
Did I break some thing ? I’m pretty sure it worked before, but I  
really don’t know what I could have done to break it.

I thought it could be an issue from Rails 2.1.2, but I got the same  
one with rails 2.1.1.

Please help !

---

<div class="post-metadata">

**Author:** ![joserwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@joserwan](https://www.ruby-forum.com/u/joserwan)\
**Post date:** [November 11, 2008, 5:08pm UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054/2 "2008-11-11T17:08:30Z")

</div>

On Nov 11, 3:40 pm, joserwan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> class Father \< Man  
> one with rails 2.1.1.

This is a quirk of single table inheritance. If you use  
require\_dependency to force all the subclasses of person to be loaded  
(eg at the bottom of person.rb) then it should work fine.

Fred

---

<div class="post-metadata">

**Author:** ![joserwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@joserwan](https://www.ruby-forum.com/u/joserwan)\
**Post date:** [November 11, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054/3 "2008-11-11T21:01:24Z")

</div>

Works fine, thank you very much !

---

<div class="post-metadata">

**Author:** ![joserwan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ea5d25/32.png) [@joserwan](https://www.ruby-forum.com/u/joserwan)\
**Post date:** [November 11, 2008, 9:04pm UTC](https://www.ruby-forum.com/t/problem-with-inheritance-and-find/153054/4 "2008-11-11T21:04:21Z")

</div>

In facts, as Person.all gave me Men and Fathers, I had

require\_dependency ‘father’ in the Man class.
