hzamani / active_record-acts_as

Simulate multi-table inheritance for activerecord models
MIT License
252 stars 86 forks source link

unknown attribute 'actable_id' while creating child class #48

Closed noozo closed 8 years ago

noozo commented 9 years ago

Hey there,

I have the following base class:

class IcAction < ActiveRecord::Base actable self.table_name = 'powerpet_ic_actions'

belongs_to :inpatient_care, foreign_key: :ic_id, class_name: 'InpatientCare' belongs_to :creator, foreign_key: :creator_id, class_name: 'VosUser' belongs_to :clinical_record, foreign_key: :clinical_record_id, class_name: 'ClinicalRecord'

validates_presence_of :inpatient_care, :creator, :scheduled_time, :actable_id, :actable_type end

and the following derived class:

class IcReadTemperatureAction < ActiveRecord::Base acts_as :ic_action self.table_name = 'powerpet_ic_read_temperature_actions' end

When i try to 'new' or 'create' the IcReadTemperatureAction class object, it fails with the error in the title. The base class table has the fields actable_id and actable_type as instructed.

Any ideas?

noozo commented 8 years ago

My bad, added the fields actable_id and actable_type but not on a migration :)