# Change the value stored in inheritance\_column

**URL:** <https://www.ruby-forum.com/t/change-the-value-stored-in-inheritance-column/133775>\
**Category:** Rails\
**Created:** [April 3, 2008, 1:09pm UTC](https://www.ruby-forum.com/t/change-the-value-stored-in-inheritance-column/133775 "2008-04-03T13:09:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chirag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecccb3/32.png) [@chirag](https://www.ruby-forum.com/u/chirag)\
**Post date:** [April 3, 2008, 1:09pm UTC](https://www.ruby-forum.com/t/change-the-value-stored-in-inheritance-column/133775/1 "2008-04-03T13:09:41Z")

</div>

I have been struggling for quite sometime with this.

Is there any way to configure the Model to store user defined value in  
the inheritance\_column instead of the default value (which is  
class\_name)

The problem I have is like this:

I have a User model and there are different models which inherit from  
this like Admin, Premium, Professional, etc.  
Each of these inherited models are identified by a field named role\_id  
in the users table and it contains integer values for e.g. 1 for  
Admin, 2 for Premium, 3 for Professional and so on.

I want to set this role\_id field as the inheritance\_column, which can  
be easily done by specifying :inheritance\_column =\> “role\_id” in the  
User Model. But how do I configure Rails to store these numerical  
values in the role\_id field, instead of the Class name?

I will really appreciate if anybody can help me out with this.

---

<div class="post-metadata">

**Author:** ![chirag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecccb3/32.png) [@chirag](https://www.ruby-forum.com/u/chirag)\
**Post date:** [April 3, 2008, 1:42pm UTC](https://www.ruby-forum.com/t/change-the-value-stored-in-inheritance-column/133775/2 "2008-04-03T13:42:03Z")

</div>

On 3 Apr 2008, at 12:08, Chirag wrote:

> this like Admin, Premium, Professional, etc.  
> Each of these inherited models are identified by a field named role\_id  
> in the users table and it contains integer values for e.g. 1 for  
> Admin, 2 for Premium, 3 for Professional and so on.
> 
> I want to set this role\_id field as the inheritance\_column, which can  
> be easily done by specifying :inheritance\_column =\> “role\_id” in the  
> User Model. But how do I configure Rails to store these numerical  
> values in the role\_id field, instead of the Class name?

Well you could overwrite those fields yourself, but then bad things  
would happen when you loaded one of those objects because Rails would  
try to create an instance of 1 instead of an instance of Admin. I  
don’t believe there’s any support for this in rails (not to say that  
it couldn’t be done but you would have to change rails itself)

Fred

---

<div class="post-metadata">

**Author:** ![chirag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecccb3/32.png) [@chirag](https://www.ruby-forum.com/u/chirag)\
**Post date:** [April 3, 2008, 4:03pm UTC](https://www.ruby-forum.com/t/change-the-value-stored-in-inheritance-column/133775/3 "2008-04-03T16:03:55Z")

</div>

When I couldn’t find it in the documentation, I thought that it might  
be the case.

Rails has strong opinion about certain things and if you try to work-  
around then it makes the life miserable.

On Apr 3, 4:41 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
