从rails 2升级到rails 3时的问题(以及ruby版本)

时间:2011-08-16 19:05:03

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-plugins

从rails 2.3.10升级到rails 3时遇到问题 我正在升级现有项目,我所做的是在代码(模型,视图等)上创建一个全新的rails 3.0.9项目副本,并更改​​rails_upgrade插件推荐的内容。

另外,我升级了宝石等..

现在,当我尝试启动服务器时,我遇到了这个问题:

/Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `include': wrong argument type Class (expected Module) (TypeError)
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `add_template_helper'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `module_eval'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `add_template_helper'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:98:in `helper'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:97:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:97:in `helper'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/action_controller/base.rb:228:in `inherited'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/bundler/gems/typus-974c0c36221d/app/controllers/admin/base_controller.rb:1
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:346:in `require_or_load'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:491:in `load_missing_constant'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183:in `const_missing'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in `const_missing'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/bundler/gems/typus-974c0c36221d/app/controllers/admin/account_controller.rb:1
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:346:in `require_or_load'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:300:in `depend_on'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:216:in `require_dependency'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:138:in `eager_load!'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:137:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:137:in `eager_load!'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:135:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:135:in `eager_load!'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:209:in `to_proc'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application/railties.rb:11:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application/railties.rb:11:in `all'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:107:in `eager_load!'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application/finisher.rb:41
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `run_initializers'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config/environment.rb:5
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:3
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:1:in `new'
from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:1

这是我的宝石文件

source 'http://rubygems.org'

gem 'rails', '3.0.9'

gem 'ar-extensions'
gem 'authlogic'
gem 'oauth'
gem 'twitter_oauth'
gem 'koala'
gem 'htmlentities'
# gem 'aws-s3', :require => 'aws/s3'
gem 'right_aws'
gem "typus", :git => "git://github.com/typus/typus.git", :branch => "3-0-stable"
gem 'flickraw'
gem 'delayed_job', '>= 2.0.4'
gem 'friendly_id', '3.1.7'
gem 'will_paginate', '~> 3.0'
gem 'rubyzip', :require => 'zip/zip'
gem 'nokogiri'
gem 'jammit'
gem 'mysql2', '< 0.3'
gem 'dalli'
gem 'closure-compiler'
gem 'yui-compressor', :require => 'yui/compressor'
gem 'geokit'
gem 'text'
gem 'fastercsv'
gem 'rapleaf_api'
gem 'hashie'
gem 'foursquare'
gem 'foursquare2'
gem 'oauth2'
gem 'google_places'
gem 'cancan'
gem 'juggernaut'
gem 'factory_girl'
gem 'whenever'
gem 'twitter'
gem 'sunspot', :require => 'sunspot'
gem 'sunspot_rails', :require => 'sunspot/rails'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'validatable'
gem 'redis'
gem 'redis-namespace'

# Use unicorn as the web server
gem 'unicorn'
gem 'capistrano'

group :development, :test do

end

这是我的插件列表:

acts_as_abusable  
acts_as_loggable  
annotate_models   
daemon_generator  
masochism         
mysql_bigint      
perform_later     
sitemap_generator
acts_as_likable   
acts_as_solr      
bitmask-attribute 
gogo_cache        
mobile-fu
oauth2_provider   
resque

我现在正在努力争取这个问题几个小时,我很乐意回答。

感谢。

编辑: 这是我完全删除了typus后的堆栈跟踪:

/Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `include': wrong argument type Class (expected Module) (TypeError)
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `add_template_helper'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `module_eval'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:123:in `add_template_helper'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:98:in `helper'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:97:in `each'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/abstract_controller/helpers.rb:97:in `helper'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/actionpack-3.0.9/lib/action_controller/base.rb:228:in `inherited'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/app/controllers/application_controller.rb:1
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:346:in `require_or_load'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:491:in `load_missing_constant'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183:in `const_missing'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in `each'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181:in `const_missing'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/app/controllers/abuse_reports_controller.rb:1
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:346:in `require_or_load'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:300:in `depend_on'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:138:in `eager_load!'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:137:in `each'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:137:in `eager_load!'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:135:in `each'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/engine.rb:135:in `eager_load!'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:108:in `eager_load!'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application/finisher.rb:41
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `run_initializers'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:77:in `send'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config/environment.rb:5
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:3
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
    from /Users/avitzurel/.rvm/gems/ruby-1.8.7-p334@gogo_web/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:1:in `new'
    from /Users/avitzurel/Dropbox/Projects/gogobot_rails3/config.ru:1

2 个答案:

答案 0 :(得分:3)

所以,它现在已经修好了......

我所做的是编辑这个文件helpers.rb:123:在`include'中(问题出在rails中) 我只输出当前正在加载的模块名称,结果是app / helpers文件夹中的文件是一个类(有人在几个月前将它放在那里)。

将此文件删除到lib文件夹后,rails很好地加载了。

感谢@arikfr提示编辑此文件: - )

答案 1 :(得分:3)

`include': wrong argument type Class (expected Module) (TypeError)

也许你的一位助手被意外重新定义为Class

# app/helpers/application_helper.rb
# make sure you never say "# class ApplicationHelper"
module ApplicationHelper

您可以使用此grep命令检查整个应用程序:

egrep -Ri "class.*Helper" *

如果您发现任何内容,请仔细检查它不应该是Module