Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ActiveRecord::Base.inheritance_column in a rails app

I want to use Single Table Inheritance using a column other than type. According to the Rails documentation - http://api.rubyonrails.org/classes/ActiveRecord/Base.html, I can do this by modifying ActiveRecord::Base.inheritance_column. How can I do this?

like image 311
Eric Baldwin Avatar asked Nov 29 '13 23:11

Eric Baldwin


1 Answers

Try the following:

class MyModel < ActiveRecord::Base
    self.inheritance_column = 'column_that_is_not_type'
end

Your migrations should work everywhere.

like image 142
Vidya Avatar answered Sep 30 '22 05:09

Vidya