RailsCasts Pro episodes are now free!

Learn more or hide this

Nianpeng Li's Profile

GitHub User: sylnp0201

Comments by Nianpeng Li

Avatar

It turns out this is a stupid question...

I figured it out, in facebook.js.coffee just change the window location

facebook.js.coffee
  $('#fb-signin').click (e) ->
    e.preventDefault()
    FB.login (response) ->
      window.location = '/accounts/auth/facebook/callback' if response.authResponse
Avatar

Hi everyone, I got a question will trying to use omniauth-facebook with devise
I followed the video(just substitute twitter with facebook) and was able to get it work.
However, I would like to customize my routes a little bit, so this is what I did:

config/routes.rb
devise_for :users, path: 'accounts', 
           controllers: { omniauth_callbacks: "omniauth_callbacks" },
           path_names: { sign_in: "login", sign_out: "logout", sign_up: "signup" }

as I expected, in my url "users/..." was changed to "accounts/...", but when I tried to login via facebook, I got this error:
Routing Error
No route matches [GET] "/users/auth/facebook/callback"

after play around with it, I got around it by adding this line:

config/routes.rb
get '/users/auth/facebook/callback', to: redirect('/accounts/auth/facebook/callback')

It works fine now, but I think there must be better solution.
Is there any way to change the returned callback url from /users/auth/facebook/callback to /accounts/auth/facebook/callback ???

Thanks!