我有模特:
Frame.rb
belongs_to :manufacturer, foreign_key: 'model'
accepts_nested_attributes_for :manufacturer, :reject_if => proc { |obj| obj.blank? }
Run Code Online (Sandbox Code Playgroud)
当我尝试使用现有制造商创建新框架时,我收到错误:
Frame.new({name: 'Name of the frame', manufacturer_attributes: {id:2}})
Run Code Online (Sandbox Code Playgroud)
错误:
Couldn't find Manufacturer with ID=2 for Frame with ID=
Run Code Online (Sandbox Code Playgroud)