Rake db:从rails2升级到rails3时迁移错误

时间:2013-10-24 10:42:41

标签: ruby-on-rails ruby-on-rails-3.2 ruby-on-rails-2

我已将rails2升级到rails3,当我尝试rake db:migrate时,我发现以下错误

**调用db:migrate(first_time)

**调用环境(first_time)

**执行环境

DEPRECATION警告:不再自动包含ActiveSupport :: Concern中的InstanceMethods模块。请直接在ActiveSupport :: Callbacks中定义实例方法。 (来自/home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/actionpack-3.2.14/lib/action_dispatch/middleware/reloader.rb:29)

**调用db:load_config(first_time)

**执行db:load_config

**执行db:migrate

rake aborted!

/home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/trace_output.rb:16:in“trace_on中的块”:无效字节US-ASCII中的序列(ArgumentError)

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/trace_output.rb:14:in `map'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/trace_output.rb:14:in `trace_on'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/application.rb:340:in `trace'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/application.rb:187:in `display_error_message'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/gems/airbrake-3.1.14/lib/airbrake/rake_handler.rb:23:in `display_error_message_with_airbrake'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/application.rb:174:in `rescue in standard_exception_handling'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/bin/rake:19:in `load'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@global/bin/rake:19:in `<main>'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/bin/ruby_executable_hooks:15:in `eval'

from /home/cis/.rvm/gems/ruby-1.9.3-p392@rails3214/bin/ruby_executable_hooks:15:in `<main>'

2 个答案:

答案 0 :(得分:1)

错误是由于某些db / migration文件中的非ascii字符引起的。 添加

#encoding: utf-8 

到你看到奇怪字符的文件

答案 1 :(得分:0)

这似乎是编码错误

将以下行添加到environment.rb文件并运行迁移

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8