Initializer for spree_social gem with facebook login integration keys

扶醉桌前 提交于 2019-12-13 07:37:55

问题


I have an app based on spree which should be integrated with Facebook. I'm doing this by spree_social gem which works fine, but i need some config file so I won't have to click through admin panel every time.

I have added ne initializer:

/config/initializers/devise.rb

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

but this does nothing.

I tried every possible tutorial and example in net, i.e. https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview or http://sleekd.com/tutorials/setting-up-omniauth-authentication-with-facebook/

but nothing works, so there must be some other error which I can't see.

The only way which works is doing:

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

which updates proper column in db but this is probably completely not the Ruby way way and it just looks bad.

I have dug in spree_social gem and there is such method:

    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

but I can't find any way of saving it into db.

Unfortunately I can't set breakpoints in config/initializers so I can't get it done as I have to test blindly configurations.


回答1:


You can use seed data to populate database with tokens.



来源:https://stackoverflow.com/questions/16612992/initializer-for-spree-social-gem-with-facebook-login-integration-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!