Created nested model setting a property on nested model before save
- by CWitty
I have two models a Company and a User the Company has_many :users and the User belongs_to :company. I have a form such as:
<%= form_for @company, data: {toggle: :validator}, novalidate: "novalidate", html: {role: :form} do |f| %>
company fields
Then in there I have
<%= f.fields_for :users, @company.users.build do |user_form| %>
A…