I've been banging my head for a while on this one. The problem comes in when saving both a new referral (the parent object) and an appointment(child) at the same time. I've done similar with other nested objects but can't seem make it work with single table inheritance -- appointments table. For some reason inverse_of doesn't pass the id of the new referral to the appointment.
class Referral < ActiveRecord::Base
has_many :appointments, class_name: 'Appointment::Base', inverse_of: :referral
accepts_nested_attributes_for :appointments
end
class Appointment::Base < ActiveRecord::Base
self.table_name = 'appointments'
belongs_to :referral, inverse_of: :appointments
end
in the view
fields_for :appointments do |a|
Any help is appreciated.