Passing foreign key constraint before creating a parent object with “accepts_nested_attributes_for” and “inverse of”.

Issue

Solution

Class Parent 
has_many :children, foreign_key: 'parent_id', inverse_of: :parent
accepts_nested_attributes_for :children
end
class Child
belongs_to :parent, inverse_of: :children
end

Started LinkedIn as well!

https://www.linkedin.com/in/tomoharu-tsutsumi-56051a126/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store