I'm trying to set up single table inheritance with a legacy schema but am having a hard time. Here is the schema for the table, bms_codes, being inherited from:
create_table "bms_codes", :id => false, :force => true do |t|
t.decimal "code_id", :null => false
t.string "code_group", :limit => 35, :null => false
t.string "code_name_short", :limit => 100
...
end
Here is code.rb. I've set up column aliases so there is a type column to inherit from.
class Code < ActiveRecord::Base
set_table_name :bms_codes
set_primary_keys :code_id, :code_group #composite keys using the composite_primary_keys gem
alias_attribute :id, :code_id
alias_attribute :type, :code_group
alias_attribute :description, :code_name_short
end
It is my understanding that inquiry_tracking_role.rb should pull in all records from Code that have a type of 'Inquiry Tracking Role'. Is this correct? In console if I type InquiryTrackingRole.all I get the same results as Code.all.
class InquiryTrackingRole < Code
end
Is what I'm trying to do possible or is our schema too fubar'ed?