I have an app with three models. At the highest level is a JobSpec
class JobSpec < ActiveRecord::Base
belongs_to :job_template, polymorphic: true, dependent: :destroy, inverse_of: :job_spec
accepts_nested_attributes_for :job_template
end
This has a polymorphic association with a job_template
, one of which is a GooddataExtract
template
class GooddataExtract < ActiveRecord::Base
has_one :job_spec, as: :job_template, inverse_of: :job_template
has_many :gooddata_reports, dependent: :destroy, inverse_of: :gooddata_extract
accepts_nested_attributes_for :gooddata_reports, reject_if: :all_blank, allow_destroy: true
end
which in turn has a one-to-many relationship with a GooddataReport
class GooddataReport < ActiveRecord::Base
belongs_to :gooddata_extract, inverse_of: :gooddata_report
end
I'm having trouble constructing a parameter hash that will create the GooddataReport
items. When I use
JobSpec.create(job_template_type: 'GooddataExtract', job_template_attributes: { gooddata_pid: 'abcdefg', gooddata_reports_attributes: { '1' => { name: 'george', report_oid: '123456' } } })
The JobSpec
and GooddataExtract
records get created just fine, but not the GooddataReport
records. There are no error messages or anything, they just fail to get created.
Any ideas what I might be missing?