Итак, я бегу в эту ошибку при попытке получить GooglePlus входа в работе в моем рельсах приложение:Получение GooglePlus входа в работе с Rails
ActionController::UrlGenerationError in Home#welcome
Showing /Users/user/Sites/new/app/views/users/_verifications.html.erb where line #22 raised:
No route matches {:action=>"passthru", :controller=>"users/omniauth_callbacks", :provider=>"googleplus"} missing required keys: [:provider]
<%= check_connection('Facebook')%>
<%= check_connection('LinkedIn')%>
<%= check_connection('Twitter')%>
<%= check_connection('GooglePlus')%> <----- this line is causing it.
метод users_helper.rb check_connection
def check_connection(provider)
if current_user.has_connection_with(provider)
link_to disconnect_path(social: provider.downcase) do
content_tag :div, class: "verified-m #{provider.downcase}-verified row" do
(content_tag :p, provider) +
(content_tag :span, 'Verified', class: "verified")
end
end
else
link_to user_omniauth_authorize_path(provider: provider.downcase) do
content_tag :div, class: "verified-m #{provider.downcase}-verified row" do
(content_tag :p, provider) +
(content_tag :span, 'Click to verify', class: "un-verified")
end
end
end
end
Devise.rb
config.omniauth :facebook, ENV['FR_FACEBOOK_KEY'], ENV['FR_FACEBOOK_SECRET'], :scope => 'email,user_birthday'
config.omniauth :twitter, ENV['TWITTER_CONSUMER_KEY'], ENV['TWITTER_CONSUMER_SECRET']
config.omniauth :linked_in, ENV['FR_LINKEDIN_KEY'], ENV['FR_LINKEDIN_SECRET'], :scope => 'r_fullprofile r_emailaddress r_network'
config.omniauth :gplus, ENV['GPLUS_KEY'], ENV['GPLUS_SECRET'], scope: 'userinfo.email, userinfo.profile'
Gemfile (отношение сниппет)
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-linkedin'
gem 'omniauth-gplus', '~> 1.0'
gem 'google-api-client', :require => 'google/api_client'
gem 'uuidtools'
А вот отношение Snippit от моего OmniauthController, голые в виду, Twitte, Facebook и LinkedIn валидация работают - возникают проблемы только с GooglePlus.
OmniauthController (отношение сниппет)
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
require 'uuidtools'
def facebook
oauthorize "Facebook"
end
def twitter
oauthorize "Twitter"
end
def linkedin
oauthorize "LinkedIn"
end
def google_plus
oauthorize "GooglePlus"
end
private
def oauthorize(kind)
@user = find_for_ouath(kind, env["omniauth.auth"], current_user)
if @user
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => kind
session["devise.#{kind.downcase}_data"] = env["omniauth.auth"]
sign_in_and_redirect @user, :event => :authentication
end
end
def find_for_ouath(provider, access_token, resource=nil)
user, email, name, uid, auth_attr = nil, nil, nil, {}
case provider
when "Facebook"
uid = access_token['uid']
email = access_token['info']['email']
auth_attr = { :uid => uid, :token => access_token['credentials']['token'],
:secret => nil, :first_name => access_token['info']['first_name'],
:last_name => access_token['info']['last_name'], :name => access_token['info']['name'],
:link => access_token['extra']['raw_info']['link'] }
when "Twitter"
uid = access_token['extra']['raw_info']['id']
name = access_token['extra']['raw_info']['name']
auth_attr = { :uid => uid, :token => access_token['credentials']['token'],
:secret => access_token['credentials']['secret'], :first_name => access_token['info']['first_name'],
:last_name => access_token['info']['last_name'], :name => name,
:link => "http://twitter.com/#{name}" }
when 'LinkedIn'
uid = access_token['uid']
name = access_token['info']['name']
auth_attr = { :uid => uid, :token => access_token['credentials']['token'],
:secret => access_token['credentials']['secret'], :first_name => access_token['info']['first_name'],
:last_name => access_token['info']['last_name'],
:link => access_token['info']['public_profile_url'] }
when 'Google+'
uid = access_token['uid']
name = access_token['info']['email']
auth_attr = { :uid => uid, :token => access_token['credentials']['token'],
:secret => access_token['credentials']['secret'], :first_name => access_token['info']['first_name'],
:last_name => access_token['info']['last_name'],
:link => access_token['info']['public_profile_url'] }
else
raise 'Provider #{provider} not handled'
end
if resource.nil?
if email
user = find_for_oauth_by_email(email, resource)
elsif uid && name
user = find_for_oauth_by_uid(uid, resource)
if user.nil?
user = find_for_oauth_by_name(name, resource)
end
end
else
user = resource
end
auth = user.authorizations.find_by_provider(provider)
if auth.nil?
auth = user.authorizations.build(:provider => provider)
user.authorizations << auth
end
auth.update_attributes auth_attr
return user
end
Что я делаю неправильно? Благодаря!
Спасибо! К сожалению, он все равно возвращает ту же ошибку, даже когда я делаю это изменение. Что бы это могло быть? Приветствия. – user3399101