I'm following this tutorial - http://tutorials.jumpstartlab.com/projects/blogger.html#i2:-adding-comments. It is building a sample blog app and so far has an Article model and is adding a Comment model. An Article has_many Comments.
They want to be able to create the comment using a form on the articles page:
<h3>Post a Comment</h3>
<%= form_for [ @article, @comment ] do |f| %>
<p>
<%= f.label :author_name %><br/>
<%= f.text_field :author_name %>
</p>
<p>
<%= f.label :body %><br/>
<%= f.text_area :body %>
</p>
<p>
<%= f.submit 'Submit' %>
</p>
<% end %>
I don't understand how this form works though. It binds two objects to the form, and it says that it'll submit to article_comments_path, which will POST to comments#create.
How does this work? How does it know what to do when it has two objects? Does the order of the objects in the array matter? Can you have more than two objects?