Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I see that your new action does have the <code>business_area_id: '2'</code> parameter but, in your controller's new action you aren't instantiating the business_area. It should look like this:</p> <pre><code>class BusinessFlowsController &lt; ApplicationController def new @business_area = BusinessArea.find params[:business_area_id] @business_flow = BusinessFlow.new # not needed here since this isn't being created yet # @business_flow.business_area_id = params[:business_area_id] end ... rest of code ... end </code></pre> <p>Now that you instantiated the <code>business_area</code>, the <code>form_for</code> should be able to correctly build the nested path which should include the <code>business_area_id</code>. Now your business_flows controller's create action should look like this:</p> <pre><code>def create @business_area = BusinessArea.find params[:business_area_id] @business_flow = @business_area.business_flows.build(business_flow_params) # assigning the parent id happens automatically in the build method # @business_flow.business_area_id = params[:business_area_id] @business_flow.updated_by = current_user.login @business_flow.created_by = current_user.login @business_flow.playground_id = current_user.current_playground_id @business_flow.owner_id = current_user.id ... rest of code ... end </code></pre> <p>To make sure the form's action includes the <code>business_area_id</code> check the rendered html. The form's attributes should look like:</p> <p><code>action="/business_areas/&lt;:business_area_id&gt;/business_flows" method="post"</code> </p> <p>where <code>&lt;:business_area_id&gt;</code> is the integer id of the parent, in your case <code>2</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload