# Form\_for not producing the correct form action=""

**URL:** <https://www.ruby-forum.com/t/form-for-not-producing-the-correct-form-action/148948>\
**Category:** Rails\
**Created:** [September 18, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/form-for-not-producing-the-correct-form-action/148948 "2008-09-18T15:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveamos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@daveamos](https://www.ruby-forum.com/u/daveamos)\
**Post date:** [September 18, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/form-for-not-producing-the-correct-form-action/148948/1 "2008-09-18T15:51:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![daveamos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@daveamos](https://www.ruby-forum.com/u/daveamos)\
**Post date:** [September 18, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/form-for-not-producing-the-correct-form-action/148948/2 "2008-09-18T15:58:52Z")

</div>

On Thu, Sep 18, 2008 at 3:51 PM, Dave A.  
\<removed\_email\_address@domain.invalid

> 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.

---

<div class="post-metadata">

**Author:** ![daveamos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a698b9/32.png) [@daveamos](https://www.ruby-forum.com/u/daveamos)\
**Post date:** [September 19, 2008, 3:32am UTC](https://www.ruby-forum.com/t/form-for-not-producing-the-correct-form-action/148948/3 "2008-09-19T03:32:16Z")

</div>

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