This extension will allow Rails STI to work a normalized type column.
This extension will allow Rails STI to work a normalized type column.
For example
create_table :people, :force => true do |t| t.string :full_name t.integer :type_id end
create_table :person_types, :force => true do |t| t.string :type_name end
class Person < ActiveRecord::Base has_normalized_sti end
class PersonType < ActiveRecord::Base end
after calling has_normalized_sti:
Configuration options are:
Override example
create_table :people, :force => true do |t| t.string :full_name t.integer :special_type_id end
create_table :person_types, :force => true do |t| t.string :special_person_type end
class SpecialPerson < ActiveRecord::Base set_table_name :people has_normalized_sti :type_class_name => 'SpecialPersonType', :type_column => 'special_person_type', :foreign_key => 'special_type_id' end
class SpecialPersonType < ActiveRecord::Base set_table_name :person_types end