I\'m trying to replace the content of a div after clicking on a link using Rails 3, remote_link :remote => true
and jQuery.
So far, I\'ve been able to ge
Another way to solve this is to add .js to the form's action (if you're using a Rails link generator you can add :format => :json). Then make sure you are responding to json in your controller.
Here's an example of a sign in form configured that way:
<%= form_for User.new, :url => session_path(:user, :format => :json), :html => {:id => "login-form", :class => "well"}, :remote => :true do |f| %>
<%= f.text_field :email %>
<%= f.password_field :password %>
<%= f.hidden_field :remember_me %>
<%= button_tag "Sign in", :class => "btn", :type => "submit" %><%= image_tag "ajax-loader.gif", :style => "display:none", :id => "login-spinner" %>
<% end %>
In the controller:
def create
respond_to do |format|
format.html{ super }
format.json do
resource = warden.authenticate!(:scope => resource_name, :recall => :failure)
return sign_in_and_redirect(resource_name, resource)
end
end
end