Link_to_remote parameters - help

I’m trying to show a preview of the comments, and I’m saving the
comments through AJAX. So, I thought that I should be able to mimic the
“comments” action for the “comments_preview” action very easily. So
far, this isn’t the case.

I have a link_to_remote tag inside of the form tag, and I don’t know how
to send the parameters that are within the form (name, site, comment)
and the id of the post it’s on (to get the current count of entries, but
that’s not as important). Basically, I don’t know how to send the
comment parameters using link_to_remote, so that I can use them in my
controller like so:

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

Then just use the @comment in the “comments_preview.rhtml” view to
display a preview… I was using the post id to get the
Comment.count(“post_id=#{params[:id]}”).

How can I send all of this data to the controller? Thanks!

You need to serialize the fields that you’d like to send to your
controller.
The serialized fields are sent using :with. Note the method ‘get’ - this
won’t work with post.

link_to_remote(‘Search’,
{ :url => {:controller => ‘controller’, :action =>
‘action’},
:method => ‘get’,
:with => ‘serialize_fields()’,
:update => ‘id of element to update’,
:complete => “…” })

Hammed