I’m having difficulty understanding this syntax:
<%= form_for([@post, @post.comments.build]) do |f| %>
usually, I see it as:
<%= form_for @post do |f| %>
what’s with the extra stuff? what does @post.comments.build do? Things to note: posts is related to comments… as in posts has many comments and a comment belongs to a post. Igot this code for this tutorial:
<h2>Add a comment:</h2>
<%= form_for([@post, @post.comments.build]) do |f| %>
<div class="field">
<%= f.label :commenter %><br />
<%= f.text_field :commenter %>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_area :body %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>