我在我的应用程序中使用omniauth-facebook,我不太确定,但我想我的路由有问题,因为它没有到达我重定向的方法。
MyApp::Application.routes.draw do
match '/auth/facebook/callback' => 'user#create'
resources :users
require 'omniauth'
class UserController < ApplicationController
def create
if User.exists?(:condition => ["email=?",auth_hash["info"]["email"]])
self.current_user = User.find(:all,:condition => ["email=?",auth_hash["info"]["email"]])
else
self.current_user = User.new(:email => auth_hash["info"]["email"])
redirect_to 'deals#generate_ticket'
end
end
def auth_hash
request.env['omniauth.auth']
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, 'XXXXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXX',
:scope => 'email'
end
也许我在路线上遗漏了一些东西,或者我没有正确安装 gem。对于每一个帮助,我将真诚地感激不尽。谢谢!