Disable single table inheritance column in Rails
Due to ActiveRecord single table inheritance in Rails, the the attribute type
is a reserved word by default. However, I like to use type
when STI is not in the picture. We can do this per model by setting inheritance_column
. Much like most things in Rails there is a sane default for convention but can be overrdiden. In this case we will be 'disabling' is by setting to nil
class Foo < ApplicationRecord
self.inheritance_column = nil
end
Now you're free to use the type
column as wish.