ここの初心者、アプリケーションに 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" }
助けてくれてありがとう。