gpt4 book ai didi

ruby-on-rails - Devise + Facebook omniauth:无法为 Devise::OmniauthCallbacksController 找到操作 'facebook'

转载 作者:数据小太阳 更新时间:2023-10-29 07:39:37 28 4
gpt4 key购买 nike

我在 SO 上找到了类似的线程,但没有一个帮助我解决了这个问题。我的路线如下:

devise_for :users do
post '/users' => 'registrations#create', :as => 'user_registration'
end
devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks"}

我也试过:

devise_for :users, :controllers => {:omniauth_callbacks => "omniauth_callbacks"}

但我还是得到了

The action 'facebook' could not be found for Devise::OmniauthCallbacksController

我什至尝试重新启动服务器,但它没有帮助我。我正在关注 this tutorial .

omniauth_callbacks_controller.rb:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)

if @user.persisted?
puts @user.inspect
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Facebook"
sign_in_and_redirect @user, :event => :authentication
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" } 

确保它符合您的 Controller 定义。

关于ruby-on-rails - Devise + Facebook omniauth:无法为 Devise::OmniauthCallbacksController 找到操作 'facebook',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17993807/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com