Skip to content

Instantly share code, notes, and snippets.

@matiasmoya
Created April 21, 2015 14:17
Show Gist options
  • Save matiasmoya/aff67cd65f4f0e1ddae5 to your computer and use it in GitHub Desktop.
Save matiasmoya/aff67cd65f4f0e1ddae5 to your computer and use it in GitHub Desktop.
Devise ajax
class DeviseSessionsController < Devise::SessionsController
clear_respond_to
respond_to :json
end
<h2>Sign in</h2>
<%=simple_form_for :user, url: session_path(:user), remote: true, html: {id: 'user_sign_in'} do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.button :submit %>
<%end%>
<h2>Sign up</h2>
<%=simple_form_for :user, url: registration_path(:user) do |f|%>
<%= f.input :username %>
<%= f.input :password %>
<%= f.input :password_confirmation %>
<%= f.button :submit %>
<%end%>
class RegistrationsController < Devise::RegistrationsController
clear_respond_to
respond_to :json
end
Rails.application.routes.draw do
#sobrescribir los controllers de devise que partician en el login / sign in para que respondan json
devise_for :users, :controllers => { omniauth_callbacks: "users/omniauth_callbacks", sessions: 'devise_sessions', registrations: 'registrations' }
devise_scope :user do
post '/users/fbasync' => "users/omniauth_callbacks#facebook_async"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment