RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: mattlondon
You can accomplish this on the server side by building the nested object in your view. Use the "build_(association name)" method, which is provided by Active Record.
Inside the _action_fields.html.erb partial:
_action_fields.html.erb
<%= f.label :step_height, "Step Height (in feet)" %> <%= f.text_field :step_height %> <% f.object.build_action %> **HERE** <%= f.fields_for :action do |builder| %> <%= render 'action_fields', f: builder %> <% end %>
Now the fields_for :action block will execute and render the action_fields partial.
fields_for :action
action_fields
Naturally you would want to use this in the sub-nested partials as well.
You can accomplish this on the server side by building the nested object in your view. Use the "build_(association name)" method, which is provided by Active Record.
Inside the
_action_fields.html.erb
partial:Now the
fields_for :action
block will execute and render theaction_fields
partial.Naturally you would want to use this in the sub-nested partials as well.