remote_form_for
remote_form_for(object_name, *args, &proc)Works like form_remote_tag, but uses form_for semantics.
5Notes
Update element after remote call
Not mentioned in the documentation, you can add :update option to the remote_form_for and pass the id of element you'd like to update after ajax action as you do with link_to_remote, for example:
<% remote_form_for "comment", :update => "form" } do |f| %>
your form here
<% end %>
Or
<% remote_form_for "comment", :update => {:success => "form", :failure => "errors"} do |f| %>
your form here
<% end %>
If you're not using resource
If you don't use resource for your remote_form_for, then :url option is necessary.
For example: <% remote_form_for "not_resource" do |f| ... %> won't work. But with :url option, it will: <% remote_form_for "not_resource", :url => { :controller => "recommend", :action => "send" } do ... %>
Using a Loading Graphic
If you want to make a little loading graphic, typically you use an animated gif (like a little spinner or something). Both link_to_remote and remote_form_for allow you to easily do this by using the :loaded and :loading triggers to call javascript.
For example:
<% remote_form_for @survey, :loading => "$('loading').show();", :loaded => "$('loading').hide();" do |f| %>
<%= submit_tag ' Save' %>
<%= image_tag "indicator_circle.gif", :style => 'display: none;', :id => 'loading' %>
<% end %>
The 'loading' parameter used for the '$' prototype selector is the id of the animated gif. It starts out hidden, and is toggled by the loading/loaded triggers.
Re: Using a Loading Graphic
You probably want to be using :complete, not :loaded, to execute Javascript when an Ajax request has finished. See: http://prototypejs.org/api/ajax/options
Common AJAX options
See the documentation for link_to_remote to see the common AJAX options, like +:before+ and +:completed+.