Tutorial by Examples

First we need a table to hold our data class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.string :password t.string :type # <- This makes it an STI t.timestamps end end end Then lets create some ...
By default STI model class name is stored in a column named type. But its name can be changed by overriding inheritance_column value in a base class. E.g.: class User < ActiveRecord::Base self.inheritance_column = :entity_type # can be string as well end class Admin < User; end Migr...
Having type column in a Rails model without invoking STI can be achieved by assigning :_type_disabled to inheritance_column: class User < ActiveRecord::Base self.inheritance_column = :_type_disabled end

Page 1 of 1