Reputation: 3100
I'm trying to implement Open Authorization within my Rails app so that users can log in with their LinkedIn accounts. When I click on a link to go to the LinkedIn authorization page, and then confirm my LinkedIn credentials, I get an error within my app:
Unknown action
The action 'linkedin' could not be found for Devise::OmniauthCallbacksController
I'm almost positive the issues lies within my routes file. Many tutorials call for the following line to be added:
devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks" }
However, I already have this line here for custom Devise logins:
devise_for :users, :controllers => { :registrations => "registrations" }
I tried switching them but that didn't work (as I expected). Is there a way to combine the two statements?
Thanks!
Issue with omniauth_callbacks_controller:
The action 'linkedin' could not be found for OmniauthCallbacksController
class OmniauthCallbacksController < ApplicationController
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def linkedin
auth = env["omniauth.auth"]
@user = User.connect_to_linkedin(request.env["omniauth.auth"],current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.linkedin_uid"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
end
Upvotes: 0
Views: 359
Reputation: 53048
Use
devise_for :users, :controllers => { :registrations => "registrations", :omniauth_callbacks => "omniauth_callbacks"}
This means that you are customizing Devise's RegistrationsController
and OmniauthCallbacksController
.
For example:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
...
end
And
class RegistrationsController < Devise::RegistrationsController
...
end
Upvotes: 1