2017-12-22 32 views
1

レール2.3.18に組み込まれて実行中のWebアプリケーションのエッジルビーとレールの更新を実行中ですルビ1.9.3。Rails 2.3.18から3.2.21にアップグレードしました。アクティブレコードクエリーで「メソッドなし」with_connection '」エラーが発生しました

私は徐々にレールバージョンを更新し、ブレークを修正しており、物事は順調に進んでいます。私は3.2.21のレールを走らせています。最初のルビーを2.0.0-p648にアップデートしました。

オンラインでこのエラーに関する何かを見つけることができないので、ここで病気が悪いと思っています。あらかじめThx。

これは、このエラーをトリガーするコントローラの行です。これは私のコードではないことに留意してください。私は8歳のシステムを更新しています。

@blogs = WpPosts.where(post_status: 'publish').order(post_date: :desc).limit(3) 

undefined method `with_connection' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007fc08067ae60> 

このエラーは

WpPosts.all 

Imが使用してデータベースMySQLとイムは、アダプタとmysql2の宝石を使用しているなど、任意のアクティブなレコードの呼び出しで発生させることができます。ここに私のgemfileがあります。

source 'http://rubygems.org' 

gem 'rails', '3.2.21' 

gem 'bigdecimal',     '1.1.0' 
gem 'business_time' 
gem 'calendar_date_select',  '2.0.0' 
gem 'gibbon',      '1.1.3' 
gem 'holidays' 
gem 'httparty',     '0.13.1' 
gem 'io-console',     '0.3' 
gem 'json',      '1.8.1' 
gem 'mini_portile',    '0.5.0' 
gem 'minitest',     '5.3.4' 
gem 'multi_json',     '1.10.1' 
gem 'multi_xml',     '0.5.5' 
gem 'journey' 

gem 'mysql2',      '~> 0.3.21' 

gem 'nokogiri',     '1.6.1' 
gem 'parseexcel',     '0.5.2' 
gem "iconv",      "~> 1.0.3" 
gem 'pdf-core',     '0.6.1' 
gem 'pdfkit',      '0.8.2' 

gem 'rubyzip',      '1.1.6' 
gem 'rufus-scheduler',    '3.0.9' 
gem 'sanitize',     '2.1.0' 
gem 'saxerator',     '0.9.4' 
# TODO address ssl_requirement error 
# gem 'ssl_requirement',    '0.1.0' 
gem 'thread_safe',     '0.3.3' 
gem 'ttfunk',      '1.4.0' 
gem 'tzinfo',      '0.3.29' 
gem 'will_paginate' 
gem 'wkhtmltopdf-binary',   '0.9.9.3' 
gem 'rails_legacy_mapper' 

group :development do 
    gem 'pry-rails' 
end 

# Needed for the new asset pipeline 
group :assets do 
    gem 'sass-rails', '~> 3.2.6' 
    # gem 'coffee-rails', '~> 3.2.2' 
    gem 'uglifier',  '>= 1.0.3' 
end 

# jQuery is the default JavaScript library in Rails 3.1 
# gem 'jquery-rails' 

この段階では、次のエラーが発生します。ここで

undefined method `with_connection' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007fc08067ae60> 

は、現在のバージョンは非常に若い一つですので、あなたはおそらく、あなたのmysql2宝石をダウングレードする必要がスタックトレース

undefined method `with_connection' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007fc08067ae60> 


    arel (2.2.3) lib/arel/visitors/to_sql.rb:16:in `accept' 
arel (2.2.3) lib/arel/visitors/bind_visitor.rb:11:in `accept' 
activerecord (3.2.21) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql' 
activerecord (3.2.21) lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all' 
activerecord (3.2.21) lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all' 
activerecord (3.2.21) lib/active_record/querying.rb:38:in `block in find_by_sql' 
activerecord (3.2.21) lib/active_record/explain.rb:41:in `logging_query_plan' 
activerecord (3.2.21) lib/active_record/querying.rb:37:in `find_by_sql' 
activerecord (3.2.21) lib/active_record/relation.rb:171:in `exec_queries' 
activerecord (3.2.21) lib/active_record/relation.rb:160:in `block in to_a' 
activerecord (3.2.21) lib/active_record/explain.rb:41:in `logging_query_plan' 
activerecord (3.2.21) lib/active_record/relation.rb:159:in `to_a' 
activerecord (3.2.21) lib/active_record/relation/finder_methods.rb:381:in `find_first' 
activerecord (3.2.21) lib/active_record/relation/finder_methods.rb:122:in `first' 
app/views/default/start.html.erb:246:in `_app_views_default_start_html_erb__1835693497152716952_70232382243240' 
actionpack (3.2.21) lib/action_view/template.rb:145:in `block in render' 
activesupport (3.2.21) lib/active_support/notifications.rb:125:in `instrument' 
actionpack (3.2.21) lib/action_view/template.rb:143:in `render' 
actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template' 
actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' 
activesupport (3.2.21) lib/active_support/notifications.rb:123:in `block in instrument' 
activesupport (3.2.21) lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
activesupport (3.2.21) lib/active_support/notifications.rb:123:in `instrument' 
actionpack (3.2.21) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' 
actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template' 
actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout' 
actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:45:in `render_template' 
actionpack (3.2.21) lib/action_view/renderer/template_renderer.rb:18:in `render' 
actionpack (3.2.21) lib/action_view/renderer/renderer.rb:36:in `render_template' 
actionpack (3.2.21) lib/action_view/renderer/renderer.rb:17:in `render' 
actionpack (3.2.21) lib/abstract_controller/rendering.rb:110:in `_render_template' 
actionpack (3.2.21) lib/action_controller/metal/streaming.rb:225:in `_render_template' 
actionpack (3.2.21) lib/abstract_controller/rendering.rb:103:in `render_to_body' 
actionpack (3.2.21) lib/action_controller/metal/renderers.rb:28:in `render_to_body' 
actionpack (3.2.21) lib/action_controller/metal/compatibility.rb:50:in `render_to_body' 
actionpack (3.2.21) lib/abstract_controller/rendering.rb:88:in `render' 
actionpack (3.2.21) lib/action_controller/metal/rendering.rb:16:in `render' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' 
activesupport (3.2.21) lib/active_support/core_ext/benchmark.rb:5:in `block in ms' 
/Users/sidylife/.rbenv/versions/2.0.0-p648/lib/ruby/2.0.0/benchmark.rb:296:in `realtime' 
activesupport (3.2.21) lib/active_support/core_ext/benchmark.rb:5:in `ms' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:40:in `block in render' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime' 
activerecord (3.2.21) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:39:in `render' 
actionpack (3.2.21) lib/action_controller/metal/implicit_render.rb:10:in `default_render' 
actionpack (3.2.21) lib/action_controller/metal/implicit_render.rb:5:in `send_action' 
actionpack (3.2.21) lib/abstract_controller/base.rb:167:in `process_action' 
actionpack (3.2.21) lib/action_controller/metal/rendering.rb:10:in `process_action' 
actionpack (3.2.21) lib/abstract_controller/callbacks.rb:18:in `block in process_action' 
activesupport (3.2.21) lib/active_support/callbacks.rb:403:in `_run__838951966072540285__process_action__2683730459786019710__callbacks' 
activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback' 
activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' 
activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks' 
actionpack (3.2.21) lib/abstract_controller/callbacks.rb:17:in `process_action' 
actionpack (3.2.21) lib/action_controller/metal/rescue.rb:29:in `process_action' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' 
activesupport (3.2.21) lib/active_support/notifications.rb:123:in `block in instrument' 
activesupport (3.2.21) lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
activesupport (3.2.21) lib/active_support/notifications.rb:123:in `instrument' 
actionpack (3.2.21) lib/action_controller/metal/instrumentation.rb:29:in `process_action' 
actionpack (3.2.21) lib/action_controller/metal/params_wrapper.rb:207:in `process_action' 
activerecord (3.2.21) lib/active_record/railties/controller_runtime.rb:18:in `process_action' 
actionpack (3.2.21) lib/abstract_controller/base.rb:121:in `process' 
actionpack (3.2.21) lib/abstract_controller/rendering.rb:45:in `process' 
actionpack (3.2.21) lib/action_controller/metal.rb:203:in `dispatch' 
actionpack (3.2.21) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' 
actionpack (3.2.21) lib/action_controller/metal.rb:246:in `block in action' 
actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:73:in `call' 
actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:73:in `dispatch' 
actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:36:in `call' 
journey (1.0.4) lib/journey/router.rb:68:in `block in call' 
journey (1.0.4) lib/journey/router.rb:56:in `each' 
journey (1.0.4) lib/journey/router.rb:56:in `call' 
actionpack (3.2.21) lib/action_dispatch/routing/route_set.rb:608:in `call' 
pdfkit (0.8.2) lib/pdfkit/middleware.rb:16:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' 
rack (1.3.10) lib/rack/etag.rb:23:in `call' 
rack (1.3.10) lib/rack/conditionalget.rb:25:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/head.rb:14:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/params_parser.rb:21:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/flash.rb:242:in `call' 
rack (1.3.10) lib/rack/session/abstract/id.rb:195:in `context' 
rack (1.3.10) lib/rack/session/abstract/id.rb:190:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/cookies.rb:341:in `call' 
activerecord (3.2.21) lib/active_record/query_cache.rb:64:in `call' 
activerecord (3.2.21) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `_run__155349648496822945__call__1222344604970663536__callbacks' 
activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback' 
activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks' 
actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/reloader.rb:65:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
railties (3.2.21) lib/rails/rack/logger.rb:32:in `call_app' 
railties (3.2.21) lib/rails/rack/logger.rb:16:in `block in call' 
activesupport (3.2.21) lib/active_support/tagged_logging.rb:22:in `tagged' 
railties (3.2.21) lib/rails/rack/logger.rb:16:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/request_id.rb:22:in `call' 
rack (1.3.10) lib/rack/methodoverride.rb:24:in `call' 
rack (1.3.10) lib/rack/runtime.rb:17:in `call' 
activesupport (3.2.21) lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
rack (1.3.10) lib/rack/lock.rb:15:in `call' 
actionpack (3.2.21) lib/action_dispatch/middleware/static.rb:83:in `call' 
railties (3.2.21) lib/rails/engine.rb:484:in `call' 
railties (3.2.21) lib/rails/application.rb:231:in `call' 
rack (1.3.10) lib/rack/content_length.rb:14:in `call' 
railties (3.2.21) lib/rails/rack/log_tailer.rb:17:in `call' 
rack (1.3.10) lib/rack/handler/webrick.rb:59:in `service' 
/Users/sidylife/.rbenv/versions/2.0.0-p648/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service' 
/Users/sidylife/.rbenv/versions/2.0.0-p648/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run' 
/Users/sidylife/.rbenv/versions/2.0.0-p648/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread' 

答えて

1

私はついに長い瞑想の後にこれを理解することができました。私は先に進んでこのバージョンをスキップし、それが解決することを期待して押し込んだだけです。どのようにして、何も起こらなかった。私はレール4に前進することでこのエラーを取り除きました...しかし、もう1つのアクティブなレコードエラーがポップアップし続けました。そこで、@tallboyは私のgemfileとgemfile.lockを見て、この新しいエラーを理解するのを助け、私のgemfileがロックされていたarelのバージョンが古い2.2.3バージョンであることを認識しました。

次に、私はこの問題に逆戻りして、このエラーのstacktraceの最初の2行がarel libを呼び出していることに気付きました。

私は3.2.xxのレールに戻って、適切なarel libとBOOMに更新しました。それは今、魅力のように動作します。 Rails 3.2.22.5は、arelバージョンを3.0.3に変更するだけで動作します。

もう一度... @tallboyは私の裏を救った!

0

です。私は、これはトリックを行う必要があります信じて

gem 'mysql2', '~> 0.3', '= 0.3.18' 

多分

gem 'mysql2', '~> 0.3', '= 0.3.15' 

スタート。

+0

私は最初のソリューションを試してみると、バンドルをインストールした後も同じエラーが表示されます。私は2番目の解決策を試してみると "Gem Load Error is:初期化されていない定数Mysql2 :: SECURE_CONNECTION – Verty00

+0

プロットが濃くなりました。) – mudasobwa

+0

いいえ葉巻:/私はちょうど今のところアップグレードを続けるつもりで、このバグがプロセス全体を通して消えてくれることを願っています。 – Verty00

関連する問題