title: Rails: Form Routes to Wrong View
body: <p>I have a form submitting to a custom action, 'add_participants', on the 'order_items' controller. It appears to submit to the correct action, but <strong>the error references an unrelated view</strong>, the view associated with 'order_items#new'.</p>
  
  <p><strong>What I have tried</strong> includes:</p>
  
  <ul>
  <li>Changing the route description from 'add_participants' to '/add_participants', and vice versa.</li>
  <li>Creating a specific 'add_participants.html.erb' file in the 'order_items' folder.</li>
  <li>Changing from &lt;%= form_for @new_oi ... %> to &lt;%= form_for OrderItem.new ... %> in various incarnations</li>
  </ul>
  
  <p><strong>The Error</strong></p>
  
  <pre><code>ArgumentError in OrderItems#add_participants
  
  Showing /path/to/app/views/order_items/new.html.erb where line #7 raised:
  
  First argument in form cannot contain nil or be empty
  
  Extracted source (around line #7):
  
  &lt;%= form_for @order_item do |f| %&gt;
  &lt;div class="field"&gt;
  &lt;%= f.hidden_field :company_id, :value =&gt; '2' %&gt;
  
  app/views/order_items/new.html.erb:7:in `_app_views_order_items_new_html_erb__1443667659032443898_70275798467060'
  app/controllers/order_items_controller.rb:78:in `block (2 levels) in add_participants'
  app/controllers/order_items_controller.rb:71:in `add_participants'
  </code></pre>
  
  <p><strong>The Route</strong></p>
  
  <pre><code>post '/add_participants', to: 'order_items#add_participants'
  </code></pre>
  
  <p><strong>The Submitting Form</strong></p>
  
  <pre><code>&lt;%= form_for @new_oi, :url =&gt; {:action =&gt; "add_participants"}, method: :post, :html =&gt; { :id =&gt; "add_participants", :class =&gt; "add_participants" } do |f| %&gt;
  </code></pre>
  
  <p><strong>Controller Action</strong></p>
  
  <pre><code>*line 71*       def add_participants
          @original_oi = OrderItem.find_by_id(session[:current_order_item_id].to_i)
          @order = @original_oi.order
          @new_oi = OrderItem.new(order_item_params)
  
          respond_to do |format|
              if @new_oi.save
                  format.html { redirect_to change_confirmation_path }
                  format.json { render action: 'show', status: :created, location: @new_oi }
              else
  *line 78*           format.html { render action: 'new', notice: "We're sorry, but we were unable to complete this purchase." }
                  format.json { render json: @new_oi.errors, status: :unprocessable_entity }
              end
          end
      end
  </code></pre>
  
  <p>Thanks in advance.</p>