# Class/Subclass and has\_many belongs\_to

**URL:** <https://www.ruby-forum.com/t/class-subclass-and-has-many-belongs-to/87762>\
**Category:** Rails\
**Created:** [March 5, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/class-subclass-and-has-many-belongs-to/87762 "2007-03-05T20:31:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 5, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/class-subclass-and-has-many-belongs-to/87762/1 "2007-03-05T20:31:38Z")

</div>

Hi:

I would appreciate some hint. I can’t modify Class A1 but I can subclass  
it so I wonder how can I get access to its belongs\_to and has\_many i.e.

Class A1 \< ActiveRecord::Base  
belongs\_to : B1  
belongs\_to : C1  
has\_many :D1

end

Class myClass \< ActiveRecord::A1  
end

The above doesn’t work… Well it doesn’t do the insert …

MyClass and A1 table are exactly the same. Any suggestions?

Regards.

---

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 8, 2007, 4:55pm UTC](https://www.ruby-forum.com/t/class-subclass-and-has-many-belongs-to/87762/2 "2007-03-08T16:55:24Z")

</div>

Try to write the second class as

Class myClass \< A1  
end

Class A1 It is not in module ActiveRecord, is it?
