title: Form_For undefined method path
body: <p>I am experimenting with nested resources:</p>
  
  <p>My routes:</p>
  
  <pre><code>  resources :conversations do
      resources :replies do
        resources :comments
      end
    end
  </code></pre>
  
  <p>I was able to get the form for replies to work with the conversation, but now I'm adding the additional complexity of getting comments to work with replies.</p>
  
  <p>The entirety of the forms are all under the conversation show path.</p>
  
  <pre><code>&lt;%= form_for([@conversation, @reply]) do |f| %&gt;
      &lt;%= render 'shared/response_form', f: f %&gt;
      &lt;%= f.submit "Reply", class: "btn btn-large btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The above form for replies works fine and gets no errors, the below form for comments gets an error:</p>
  
  <p>undefined method `reply_comments_path'</p>
  
  <pre><code>&lt;%= form_for([@reply, @comment]) do |f| %&gt;
      &lt;%= render 'shared/response_form', f: f %&gt;
      &lt;%= f.submit "Comment", class: "btn btn-large btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Here is my conversations controller for show, this is where I think the problem is:</p>
  
  <pre><code>  def show
      @conversation = Conversation.find(params[:id])
      @replies = @conversation.replies
      @reply = current_user.replies.build
      #If I change the above line to @conversations.replies.build 
      #it breaks the ability to show replies above the form.
  
      @comments = @reply.comments
      @comment = @reply.comments.build    
    end
  </code></pre>
  
  <p>However, someone else suggested doing this:</p>
  
  <pre><code>&lt;%= form_for([@conversation, @reply, @comment]) do |f| %&gt;
      &lt;%= render 'shared/response_form', f: f %&gt;
      &lt;%= f.submit "Comment", class: "btn btn-large btn-primary" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>But it only ended up with a routing error: </p>
  
  <pre><code>No route matches {:controller=&gt;"comments", :format=&gt;nil, :conversation_id=&gt;#&lt;Conversation id: 3, content: "Goes here.", user_id: 1, created_at: "2012-12-10 21:20:01", updated_at: "2012-12-10 21:20:01", subject: "Another conversation"&gt;, :reply_id=&gt;#&lt;Reply id: nil, content: nil, user_id: 1, created_at: nil, updated_at: nil, conversation_id: nil&gt;}
  </code></pre>
  
  <p>I always get this undefined method path error when I try making new forms and I always manage to forget what I did wrong. The answer never seems to be the routes.</p>
  
  <p>EDIT:</p>
  
  <p>Under the create section in the controller I have:</p>
  
  <pre><code>@replies = @conversation.replies
  @reply = current_user.replies.build
  #If I change the above line to @conversations.replies.build 
  #it breaks the ability to show replies above the form.
  </code></pre>
  
  <p>I have no idea why @reply = @conversation.replies.build breaks the ability to show the existing replies.  I get an error saying it can't convert nil to a number, and can't see the reply.created_at or reply.content.  Whatever is causing that may be a clue as to why I'm having this problem.  However, in the replies controller I AM using </p>
  
  <pre><code>@reply = conversation.replies.build(content: params[:reply][:content], user_id: current_user.id)
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Just to add, Stackoverflow does something very similar to what I'm trying to achieve here, except that you can comment on the questions as well as the answers.</p>