新手,我在应用程序中设置了omniauth-facebook,一切正常,我唯一的问题是我想在身份验证后重定向到另一个页面,但我不太明白。我的第一个解决方案是添加一个路由来匹配 auth/facebook/callback 到“sessions#new”它不起作用。我尝试的另一件事是在控制器中添加重定向,也不起作用,重定向到特定页面的正确方法是什么?
控制器
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
sign_in_and_redirect , :event => :authentication #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "sign in successfuly") if is_navigational_format?
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
路线
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
谢谢你的帮助 。