# Polymorphisme and single table inheritance

**URL:** <https://www.ruby-forum.com/t/polymorphisme-and-single-table-inheritance/141663>\
**Category:** Rails\
**Created:** [June 28, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/polymorphisme-and-single-table-inheritance/141663 "2008-06-28T19:25:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [June 28, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/polymorphisme-and-single-table-inheritance/141663/1 "2008-06-28T19:25:05Z")

</div>

Hi

I use STI and polymorphisme as following :

class Franchise \< Company  
…  
has\_one :notebook, :as =\> :notebookable, :dependent =\> :destroy  
…  
def after\_create  
…  
self.create\_notebook  
end

class Notebook \< ActiveRecord::Base  
belongs\_to :notebookable, :polymorphic =\> true  
…  
end

BUT the created notebook record has :notebookable\_type = ‘Company’,  
whicj is not right, should be ‘Franchise’…

is it correct or should I add another parameter somewhere ?

thanks for your advices…

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [July 30, 2008, 5:09am UTC](https://www.ruby-forum.com/t/polymorphisme-and-single-table-inheritance/141663/2 "2008-07-30T05:09:10Z")

</div>

> end
> 
> class Notebook \< ActiveRecord::Base  
> belongs\_to :notebookable, :polymorphic =\> true  
> …  
> end
> 
> BUT the created notebook record has :notebookable\_type = ‘Company’,  
> whicj is not right, should be ‘Franchise’…
> 
> is it correct or should I add another parameter somewhere ?

Did you ever get an answer to this? I am faced with a similar problem.
