The problem is what Frame.new
is the new record, when ActiveRecord reaches the parameter manufacturers_attributes
, it searches for an association manufacturers_attributes
for Frame.new
, which is unsaved and therefore does not have an identifier with which to search.
I recommend starting with an existing record manufacturer
and simply creating such a frame manufacturer.frames.create(frame_params)
(assuming a one-to-many relationship).
, , manufacturer_attributes
:
accepts_nested_attributes_for :manufacturer
def manufacturer_attributes=(attributes)
if attributes['id'].present?
self.manufacturer = Manufacturer.find(attributes['id'])
end
super
end
, , manufacturer_attributes
, .