Mihail Davydenkov
Mihail Davydenkov

Reputation: 1861

Conditionals app_id for omniauth.rb. Localhost and heroku without changing omniauth.rb

I've got a rails 4 application with facebook authentication and I've deployed it on heroku. Sometimes i debug my app using localhost. That's why I create two apps on facebook developers page - the first using heroku_address (app_id 1 and app_secret 1) and the second one using localhost_address (app_id 2 and app_secret 2).

My question is how should I configure my omniauth.rb so that my_rails_app will use app_id 1 set if heroku_adress or app_id 2 set if localhost. I would like my appliction_authentication to work both on localhost and on heroku_url without changing omniauth.rb.

Here is my omniauth.rb:

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
     provider :facebook, '229517473864398', '88c42ceadf5ac4baeb36333a5fc990ac' #, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}

   # provider :facebook, '1397526230476094', '5fd1171c4781525b9e5a873c095f4d6e' #, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
   end
 end

Thanks in advance for your attention!

Upvotes: 0

Views: 466

Answers (1)

apneadiving
apneadiving

Reputation: 115541

The best way is to put those information in ENV. It's easy to do with heroku, use the figaro gem if needed.

Upvotes: 2

Related Questions