0

我有一个基于 spree 的应用程序,应该与 Facebook 集成。我正在通过 spree_social gem 执行此操作,它工作正常,但我需要一些配置文件,所以我不必每次都点击管理面板。

我添加了 ne 初始化程序:

/config/initializers/devise.rb

require 'omniauth-facebook'
Devise.setup do |config|
  config.omniauth :facebook, KEY, SECRET
end

但这无济于事。

我在网络中尝试了所有可能的教程和示例,即https://github.com/plataformatec/devise/wiki/OmniAuth:-Overviewhttp://sleekd.com/tutorials/setting-up-omniauth-authentication-with- Facebook/

但没有任何效果,所以一定有其他一些我看不到的错误。

唯一可行的方法是:

ActiveRecord::Base.connection.execute(SQL query here)

它更新了 db 中的正确列,但这可能完全不是 Ruby 方式,它看起来很糟糕。

我挖了 spree_social gem,有这样的方法:

    def update_oauth_method
        auth_method = params[:authentication_method]
        if auth_method[:active] == "true" && auth_method[:environment] == ::Rails.env
          Devise.setup do |config|
            config.omniauth auth_method[:provider], auth_method[:api_key],    auth_method[:api_secret]
         end
       end
    end

但我找不到任何方法将其保存到数据库中。

不幸的是,我无法在 config/initializers 中设置断点,所以我无法完成它,因为我必须盲目地测试配置。

4

1 回答 1

0

您可以使用种子数据来使用令牌填充数据库。

于 2013-09-25T12:30:39.247 回答