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.