Form_for not producing the correct form action=""

Hi everyone,

I’m using RESTful routes and am trying to implement a simple comment
form. For some reason when I submit the form I get an error that it’s
trying to render the index action, instead of processing the comment and
returning me to the same page. Here’s my form_for:

<% form_for @comment do |f| %>
<%= f.text_area :body, :class => “small_textarea” %>

Post your comment

<% end %>

Here’s what I have in the HTML:

Shouldn’t it be: <form action="/comments/create"…>? It doesn’t seem to
understand that I want it to create the comment. Even when I do this:

<% form_for @comment, :url => {:controller => “comments”, :action =>
“create”} do |f| %>

It gives me the exact same URL. What am I missing here?

On Thu, Sep 18, 2008 at 3:51 PM, Dave A.
<[email protected]

wrote:

Post your comment <% end %>

Here’s what I have in the HTML:

This is correct.

The form_for will use a POST to create a new Comment, and
a PUT to update an existing one, and it figures that out for you.

Do you have a resources entry for the comments in your routes.rb
à la

map.resources :comments

You can run rake routes in your application directory to see the
Restful routes available.

Thanks! I realized that I didn’t restart my server after I edited my
routes file. Now it works!