Reputation: 4127
I'm trying to follow this link for help integrating the linkedin gem with an omniauthable devise Rails platform.
http://renderedtext.com/blog/2011/08/17/how-to-use-linkedin-gem-with-omniauth/
Two quick questions!
Where would the bottom "class LinkedinFactory" file be located within the app, and what would it be called? I don't see a directory/filename in the link above.
My application currently fails when I try to log in through linkedin saying:
NoMethodError in OmniauthCallbacksController#linkedin
undefined method `create_linkedin_connection' for nil:NilClass
Where and how would I define the "create_linkedin_connection" method? It is called in line 3 of the omniauth_callbacks.rb controller:
def linkedin
omniauth_hash = env["omniauth.auth"]
current_user.create_linkedin_connection(
:token => omniauth_hash["extra"]["access_token"].token,
:secret => omniauth_hash["extra"]["access_token"].secret,
:uid => omniauth_hash["uid"]
)
redirect_to root_path, :notice => "You've successfully connected your LinkedIn account."
end
Thank you!
Upvotes: 0
Views: 490
Reputation: 2447
1) A user defined class should usually get put in your lib directory
2) You are calling the "create_linkedin_connection" method on current_user, in which case that method needs to be in the Users controller. Once that has been changed then you need to make sure to specify the route in your routes.rb file. The route should be defined as so
match '/auth/callback', to: 'users#create_linkedin_connection'
Upvotes: 0