1

我已经在我的应用程序中设置了设计。我想添加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)

此警告似乎源自此设计文件

我的宝石文件

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'

用户.rb

class User < ActiveRecord::Base
  devise :database_authenticatable, :registerable, :omniauthable,
         :recoverable, :rememberable, :trackable, :validatable
end

设计.rb

config.omniauth :facebook, OMNIAUTH_VAR['FACEBOOK_APP_ID'], OMNIAUTH_VAR['FACEBOOK_APP_SECRET'], scope: 'email'

将以下内容添加到devise.rb也不起作用

require 'omniauth-facebook'
require 'omniauth'

任何帮助将不胜感激。谢谢!

4

2 回答 2

2

解决了!显然,这是一个独角兽问题。重启独角兽没有帮助。必须使用以下命令手动停止和重新启动 unicorn:

/etc/init.d/unicorn_appname stop
/etc/init.d/unicorn_appname start

你也可以这样做:

sudo service unicorn_appname stop
sudo service unicorn_appname start

将“appname”替换为您的应用名称。

回答信用

于 2013-07-30T11:31:35.120 回答
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
于 2013-07-30T07:49:47.560 回答