1

我使用带有 devise 的 rails4 创建应用程序,omniauth 正在尝试 facebook 集成。最初使用 facebook 登录并验证凭据,回调后重定向到我的应用程序并通过

路由错误:未初始化的常量 Users::OmniauthCallbacksController

我展示了与设计 fb 相关的代码

配置/初始化器/devise.rb

require "omniauth-facebook"
  config.secret_key = 'ef8c3900aebe5cc02feb1dfafb084b2ed35412b43b9424315ac192336f3d16389449739f9a4d451621a912be899af0b9d1ce66fde56487e7edda30ba3997a2cd'
  config.omniauth :facebook, '############', '######################', :strategy_class => OmniAuth::Strategies::Facebook

config/routes.rb devise_for:用户,控制器:{omniauth_callbacks:“用户/omniauth_callbacks”}

  devise_scope :user do
    get 'sign_in', :to => 'devise/sessions#new'
    get 'sign_out', :to => 'devise/sessions#destroy'
    root to: "devise/sessions#new"
  end

和我的 view/layout/application.html.erb (用于 fb 脚本)

<div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        // init the FB JS SDK
        FB.init({
          appId      : '##########',                        // App ID from the app dashboard
          channelUrl : 'http://localhost:3000/channel.html', // Channel file for x-domain comms
          status     : true,                                 // Check Facebook Login status
          xfbml      : true                                  // Look for social plugins on the page
        });


        // Additional initialization code such as adding Event Listeners goes here
      };

      // Load the SDK asynchronously
      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/en_US/all.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));
    </script>

我尝试了很多次,但我得到了同样的错误请为这个问题提供你有价值的解决方案

提前致谢。

4

0 回答 0