On Thu, Sep 18, 2008 at 3:51 PM, Dave Amos <[EMAIL PROTECTED]
> wrote:

>
> 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" %>
>    <button type="submit" class="button positive">
>      Post your comment
>    </button>
> <% end %>
>
> Here's what I have in the HTML:
>
> <form action="/comments" class="new_comment" id="new_comment"
> method="post">


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.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to