Unicorn and omniauth-facebook - uninitialized constant OmniAuth

佐手、 提交于 2019-12-10 17:41:34

问题


So I am trying to get omniauth-facebook to work in my production env. It works fine locally on my machine using POW.

My prod env is ubuntu with nginx/unicorn and code is Rails 3.2.13, the errors from unicorn are:

E, [2013-05-20T15:51:13.900829 #8737] ERROR -- : uninitialized constant OmniAuth (NameError)
/home/web/apps/****/releases/20130520041958/config/initializers/omniauth.rb:1:in `<top (required)>'

So from what I could find I try adding require 'omniauth/facebook' above the configure block to my production.rb file and now I get:

/home/web/apps/****/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- omniauth/facebook (LoadError)

gemfile looks like this:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'pg'
gem 'bcrypt-ruby', '3.0.1'
gem 'jquery-rails', '2.2.1'
gem 'omniauth-facebook'
gem 'simple_form'

initializers file looks like this:

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']
end

any ideas anyone? Am I missing here. I followed rails cast 360 and as I said works locally in POW.


回答1:


Hi all figured it out,

Firstly i needed to have:

require 'omniauth-facebook'

not

require 'omniauth/facebook'

in the initializers file and when restarting unicorn do a stop, then start command not a restart command.



来源:https://stackoverflow.com/questions/16643832/unicorn-and-omniauth-facebook-uninitialized-constant-omniauth

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