我已经尝试了书中的所有技巧和堆栈中的所有可能的解决方案。但仍然无法找出问题所在。该程序在回叫启动阶段暂停,并显示faraday connection : timed out
。我有以下代码:
gem 'omniauth', '~> 1.3', '>= 1.3.1'
gem 'omniauth-facebook'
Routes.rb
devise_for :users,
:path => '',
:path_names => {:sign_in => 'login', :sign_out => 'logout', :edit => 'profile' },
:controllers => {:omniauth_callbacks => 'omniauth_callbacks'}
/Controller.rb
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.from_omniauth(request.env["omniauth.auth"])
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"].except("extra")
redirect_to new_user_registration_url
end
end
end
/user.rb
class User < ApplicationRecord
def self.from_omniauth(auth)
user = User.where(email: auth.info.email).first
if user
return user
else
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.email = auth.info.email
user.image = auth.info.image
user.password = Devise.friendly_token[0,20]
user.firstname = auth.info.first_name
user.lastname = auth.info.last_name
user.phonenumber == '0000000000'
user.tc == true
user.year == true
end
end
end
end
/devise.rb
config.omniauth:facebook,ENV['FACEBOOK_ID'],ENV['FACEBOOK_SECRET'],scope:'email',info_fields:'email,first_name,last_name'