I have a custom registrations controller for devise set up, which is this:
devise_for :users, controllers: {registrations: "registrations"}
and in the controller:
class RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
user_path(resource)
end
end
It works great.
However I also have omniauth authentication, which again works great…by itself:
devise_for :users, controllers: {omniauth_callbacks: "omniauth_callbacks"}
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def all
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
flash.notice = "Signed in!"
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to sign_up_path
end
end
alias_method :linkedin, :all
alias_method :twitter, :all
end
However as you can probably already see my problem – I’m not sure how to get them to work together, as they both start with ‘devise_for :users’ and so whichever way round I place them in the routes file, one won’t work.
How can I get them both working at the same time, so that the registrations controller only overrides the ‘edit’ and ‘update’ actions, while the omniauth_callbacks controller handles authentication?
Thanks
In routes.rb, you can put comma seperated paths for
devise_forlike this –This will work.