Rails 3到Rails 5迁移ActiveRecord问题

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (7)

Rails用Jruby从2.3.8升级到5.1.2

升级gem'activerecord-jdbc-adapter'时出现ActiveRecord问题

我开始担任初级Rails开发人员,我的第一个任务是将Jruby 1.5.3(Ruby 1.8.7)中编写的旧版Rails 2.3.8应用程序更新为Jruby 9.1.12中的Rails 5.1.2(Ruby 2.3) 0.3)。它由222个控制器和122个模型组成,并且仅吐出由Java Swing桌面应用程序使用的XML。搜索我发现最好的方法是从一个小版本到另一个小版本一步一步地纠正国际米兰的所有问题。我在两周内达到3.0.12版本而没有警告就留下了应用程序,但我被要求直接转到Jruby 9.XX和Rails 5.1.X. 有一些困难,我得到服务器,但当我尝试登录应用程序时,我收到此错误。我怀疑jdbc适配器gem,但5.0pre1以下的任何gem都适用于Rails 5。这可能只是DB的解析错误吗?我应该继续我带的周期吗?

注意:该应用程序没有测试套件,并且有八个模块覆盖了一些Rails核心方法。

Started POST "/login/login_xml" for 127.0.0.1 at 2017-08-03 12:21:03 -0500
  ActiveRecord::SchemaMigration Load (0.0ms)  SELECT `schema_migrations`.* 
FROM `schema_migrations`

NoMethodError (undefined method `to_sym' for nil:NilClass
Did you mean?  to_s):

activerecord (5.0.4) lib/active_record/attribute_methods/time_zone_conversion.rb:88:in `create_time_zone_conversion_attribute?'
activerecord (5.0.4) lib/active_record/attribute_methods/time_zone_conversion.rb:78:in `block in inherited'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:62:in `block in matching'
org/jruby/RubyArray.java:2565:in `select'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:61:in `matching'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:57:in `decorators_for'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:48:in `apply'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:30:in `block in load_schema!'
org/jruby/RubyHash.java:1343:in `each'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:29:in `load_schema!'
activerecord (5.0.4) lib/active_record/model_schema.rb:455:in `block in load_schema'
C:/jruby-9.1.12.0/lib/ruby/stdlib/monitor.rb:214:in `mon_synchronize'
activerecord (5.0.4) lib/active_record/model_schema.rb:452:in `load_schema'
activerecord (5.0.4) lib/active_record/model_schema.rb:343:in `columns_hash'
activerecord (5.0.4) lib/active_record/querying.rb:41:in `find_by_sql'
activerecord (5.0.4) lib/active_record/relation.rb:702:in `exec_queries'
activerecord (5.0.4) lib/active_record/relation.rb:583:in `load'
activerecord (5.0.4) lib/active_record/relation.rb:260:in `records'
activerecord (5.0.4) lib/active_record/relation/delegation.rb:38:in `map'
activerecord (5.0.4) lib/active_record/migration.rb:1031:in `block in get_all_versions'
activesupport (5.0.4) lib/active_support/deprecation/reporting.rb:36:in `silence'
activesupport (5.0.4) lib/active_support/deprecation/instance_delegator.rb:20:in `silence'
activerecord (5.0.4) lib/active_record/migration.rb:1029:in `get_all_versions'
activerecord (5.0.4) lib/active_record/migration.rb:1043:in `needs_migration?'
activerecord (5.0.4) lib/active_record/migration.rb:573:in `check_pending!'
activerecord (5.0.4) lib/active_record/migration.rb:549:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.4) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.4) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.4) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.4) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.4) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.4) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.4) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.3) lib/rack/method_override.rb:22:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
railties (5.0.4) lib/rails/engine.rb:522:in `call'
puma-3.9.1 (java) lib/puma/configuration.rb:224:in `call'
puma-3.9.1 (java) lib/puma/server.rb:602:in `handle_request'
puma-3.9.1 (java) lib/puma/server.rb:435:in `process_client'
puma-3.9.1 (java) lib/puma/server.rb:299:in `block in run'
puma-3.9.1 (java) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (16.0ms)
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (16.0ms)
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (12.0ms)
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (142.0ms)
提问于
用户回答回答于

最简单的答案是你需要立即推回请求直接跳到5.1。你正在准备失败。甚至可能无法从您当前的版本转到5.1,并且没有深入研究您的项目并分析您目前依赖的宝石,也无法知道。

您正试图将一个极其过时的项目用于现代版本,这将花费大量时间来正确完成。这就是为什么现代版本的年度/双年度更新很重要,因此您不会积累如此高水平的技术债务。

请与更高级别的开发人员或您的经理讨论此无理要求。

扫码关注云+社区

领取腾讯云代金券