未定义的方法`include?' for nil:从rails 3.1.3升级到rails 3.2.2之后的NilClass

时间:2012-03-11 11:11:52

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2

使用命令rake rails:upgrade将我的应用从rails 3.1.3上传到rails 3.2.2 输入localhost:3000

时出现以下错误
undefined method `include?' for nil:NilClass

我的服务器日志说

NoMethodError (undefined method `include?' for nil:NilClass):
  oa-core (0.3.2) lib/omniauth/builder.rb:29:in `call'
  client_side_validations (3.1.4) lib/client_side_validations/middleware.rb:18:in `call'
  warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
  warden (1.1.1) lib/warden/manager.rb:34:in `catch'
  warden (1.1.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.1) lib/rack/etag.rb:23:in `call'
  rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
  rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
  activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__855497111__call__557125978__callbacks'
  activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
  railties (3.2.2) lib/rails/engine.rb:479:in `call'
  railties (3.2.2) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /home/rzaartz/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
  /home/rzaartz/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
  /home/rzaartz/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'


  Rendered /home/rzaartz/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.2ms)
  Rendered /home/rzaartz/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (26.7ms)
  Rendered /home/rzaartz/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (155.4ms)

我该如何解决这个问题。

我的宝石文件

source 'http://rubygems.org'

gem 'rails', '3.2.2'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
  gem 'twitter-bootstrap-rails'
end

gem 'jquery-rails'
gem 'devise'
gem 'paperclip'
gem 'redcarpet'
gem 'make_flaggable', :git => 'git://github.com/cavneb/make_flaggable.git'
gem 'nokogiri'
gem 'gravtastic'
gem "impressiongram", "~> 0.0.5"
gem 'impressionist'
#gem 'sunspot_rails'
gem 'event-calendar', :require => 'event_calendar'
gem "oa-oauth", :require => "omniauth/oauth"
gem "omniauth"
gem "will_paginate", "~> 3.0.0"
gem "cancan"
gem "tabs_on_rails", "~> 2.0.2"
gem 'albino'
gem 'youtube_it'
gem 'rack-pjax'
#gem 'formtastic'
gem 'amistad'
gem 'jw_player_helper'
gem 'best_in_place'
gem 'roadie'
gem "googlecharts", :require => "gchart"
gem 'delayed_job'
gem 'delayed_paperclip'
gem 'ckeditor'
gem 'private_pub'



gem "devise_rpx_connectable", :git => 'git://github.com/TheEmpty/devise_rpx_connectable.git'





 gem 'capistrano'


group :development, :test do
  # Pretty printed test output
  gem 'turn', :require => false
  gem 'rspec-rails'
  gem 'capybara'
  gem 'launchy'
  gem "factory_girl_rails"
  gem "capybara"
  gem "database_cleaner"
  gem "guard"
  gem "guard-rspec"
  gem "fakeweb"
  gem "simplecov", :require => false
  #gem 'client_side_validations'
end

1 个答案:

答案 0 :(得分:0)

问题是你使用的是过时版本的OmniAuth(0.3.2)。升级到版本1.x以解决此问题。请参阅:https://github.com/intridea/omniauth

请注意,从0.3.2到1.x有几处重大变化,因此请仔细阅读升级说明:https://github.com/intridea/omniauth/wiki/Upgrading-to-1.0

更新:作为此升级过程的一部分,您应该从Gemfile中删除oa-oauth引用。

更新2:关于仔细阅读升级说明的警告没有随意抛出:这不是一个完全无关紧要的升级,必须注意使其正常工作