Need help regarding RESTful and Ajax Form

I’m trying to create an ajax form but I’m a little confused on the
syntax I should use for REST.

I recently created a comments model which belongs to poems, and poem
has many comments.

I set up the routes like so:

map.resources :poems do |poems|
   poems.resources :comments
end

My Comments Controller

class CommentsController < ApplicationController
  def new
    @comment = Comment.new
  end

  def create
    @comment = Comment.new(params[:comment])

     respond_to do |format|
        if @comment.save
          flash[:notice] = 'Poem was successfully created.'
          format.html { redirect_to comment_url(@poem, @comment) }
          format.xml  { head :created, :location => comment_url(@poem,
@comment) }
        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @comment.errors.to_xml }
        end
      end
  end
end

But I’m rather confused on what I should be doing to create an ajax
form for comments, while viewing a poem.

poem show.rhtml

<p><% form_remote_tag(:update => "comments",
                   :url => { :action => :new },
                   :position => "top" ) %>
    New Comment:
    <%= text_field_tag :new %>
    <%= submit_tag 'Save' %>
  <% end_form_tag -%></p>

I did something like that, but I don’t think that’s right.

If anyone could point me in the right direction, I’d appreciate it.
Thanks!

:position => “top” ) %>
New Comment:
<%= text_field_tag :new %>
<%= submit_tag ‘Save’ %>
<% end_form_tag -%>


[/code]
I did something like that, but I don’t think that’s right.

If anyone could point me in the right direction, I’d appreciate it.
Thanks!

this might work for you (if you’re using 1.2 or edge):

<% remote_form_for :comment :url => new_comment_path(@poem) do |f| -%>
<%= f.text_field :new -%>
<%= submit_tag ‘Save’ -%>
<% end -%>