我已经设计好了我的应用程序。我想添加omniauth-facebook gem(用于facebook身份验证)。该设置在开发和登台环境中工作正常,但在我的生产环境中给出了以下错误:
Could not load 'omniauth'. Please ensure you have the omniauth gem >= 1.0.0 installed and listed in your Gemfile.
/home/slaxman/apps/itextbook/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- omniauth (LoadError)
此警告似乎源于此devise file。
我的 Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.11'
group :production do
gem 'pg', '0.14.1'
gem 'therubyracer','0.11.4'
gem 'execjs', '1.4.0'
end
group :assets do
gem 'sass-rails', '~> 3.2.6'
gem 'jquery-rails', '~> 2.2.1'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '~> 1.3.0'
gem 'bootstrap-sass', '~> 2.3.1.2'
gem 'bootswatch-rails', '~> 0.5.0'
end
gem 'unicorn', '~> 4.6.2'
gem 'capistrano', '~> 2.14.2'
gem "multi_json", "~> 1.2.0"
gem 'devise' , '~> 2.2.4'
gem 'omniauth-facebook', '1.4.0'
gem 'cancan', '~> 1.6.8'
gem 'omniauth', '>= 1.0.0'
user.rb
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validatable
end
在 devise.rb
中config.omniauth :facebook, OMNIAUTH_VAR['FACEBOOK_APP_ID'], OMNIAUTH_VAR['FACEBOOK_APP_SECRET'], scope: 'email'
将以下内容添加到 devise.rb 也不起作用
require 'omniauth-facebook'
require 'omniauth'
任何帮助将不胜感激。谢谢!
答案 0 :(得分:2)
解决了!显然,这是一个独角兽问题。重启独角兽并没有帮助。必须使用以下命令手动停止并重新启动独角兽:
/etc/init.d/unicorn_appname stop
/etc/init.d/unicorn_appname start
你也可以这样做:
sudo service unicorn_appname stop
sudo service unicorn_appname start
替换&#39; appname&#39;使用您的应用名称。
答案 1 :(得分:0)
这可能不是正确的顺序,这是我的Gemfile的一个例子。希望这会有所帮助。
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'pg'
gem 'jquery-rails'
gem 'devise'
gem 'omniauth-facebook'
gem 'acts_as_votable'
gem 'gibbon'
gem 'foreman'
gem 'ruby-sendhub'
gem 'bitly'
gem 'rack-rewrite'
gem 'twitter'
gem 'hpricot'
gem 'premailer-rails3'
gem 'kaminari'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
group :test, :development do
gem "foreman"
gem "rspec-rails"
gem "factory_girl_rails"
gem "capybara"
gem "guard-rspec"
gem "spork"
gem "guard-spork"
gem "launchy"
gem "database_cleaner"
end