我们有一个庞大而复杂的rails应用程序,我们开始从2.8迁移到3.1
控制台最终启动,User.last
返回预期值。
但是,当我们启动服务器时,User.last
最终会导致postgresql适配器中的参数错误。
**ArgumentError in HomeController#index
wrong number of arguments (3 for 2)
Backtrace:**
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:546:in `log'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:546:in `exec_query'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:1027:in `select'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/database_statements.rb:9:in `select_all'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/query_cache.rb:74:in `cache_sql'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'
activerecord (3.1.0.rc1) lib/active_record/base.rb:469:in `find_by_sql_without_trace_ActiveRecord___self_name__find_by_sql'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/method_tracer.rb:319:in `find_by_sql'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/method_tracer.rb:314:in `find_by_sql'
activerecord (3.1.0.rc1) lib/active_record/relation.rb:106:in `to_a'
activerecord (3.1.0.rc1) lib/active_record/relation/finder_methods.rb:382:in `find_last'
activerecord (3.1.0.rc1) lib/active_record/relation/finder_methods.rb:142:in `last'
activerecord (3.1.0.rc1) lib/active_record/base.rb:440:in `__send__'
activerecord (3.1.0.rc1) lib/active_record/base.rb:440:in `last'
app/controllers/home_controller.rb:23:in `index'
actionpack (3.1.0.rc1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.0.rc1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.0.rc1) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.0.rc1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.0.rc1) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:461:in `_run__738958071__process_action__199225275__callbacks'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:386:in `send'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `send'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0.rc1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.0.rc1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.1.0.rc1) lib/active_support/notifications.rb:55:in `instrument'
activesupport (3.1.0.rc1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.0.rc1) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.0.rc1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.0.rc1) lib/action_controller/metal/params_wrapper.rb:202:in `process_action'
actionpack (3.1.0.rc1) lib/action_controller/metal/rescue.rb:17:in `process_action'
activerecord (3.1.0.rc1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `process_action'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:252:in `perform_action_with_newrelic_trace'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/method_tracer.rb:141:in `trace_execution_scoped'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:247:in `perform_action_with_newrelic_trace'
newrelic_rpm (2.13.4.rum4) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
actionpack (3.1.0.rc1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.0.rc1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.0.rc1) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.0.rc1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.0.rc1) lib/action_controller/metal.rb:236:in `action'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:152:in `call'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:93:in `recognize'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.8.1) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.8.1) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/routing/route_set.rb:531:in `call'
mongo_mapper (0.9.1) lib/mongo_mapper/middleware/identity_map.rb:10:in `call'
newrelic_rpm (2.13.4.rum4) lib/new_relic/rack/developer_mode.rb:20:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.0) lib/rack/etag.rb:23:in `call'
rack (1.3.0) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.0) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.0) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/cookies.rb:321:in `call'
activerecord (3.1.0.rc1) lib/active_record/query_cache.rb:54:in `call'
activerecord (3.1.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `call'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `send'
activesupport (3.1.0.rc1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.0) lib/rack/sendfile.rb:102:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0.rc1) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.0) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.0) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0.rc1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.0) lib/rack/lock.rb:34:in `call'
actionpack (3.1.0.rc1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0.rc1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0.rc1) lib/rails/engine.rb:438:in `call'
railties (3.1.0.rc1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.0) lib/rack/handler/webrick.rb:59:in `service'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:162:in `start'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:95:in `start'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:92:in `each'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:92:in `start'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:23:in `start'
/Users/jluckett/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.3.0) lib/rack/handler/webrick.rb:13:in `run'
rack (1.3.0) lib/rack/server.rb:265:in `start'
railties (3.1.0.rc1) lib/rails/commands/server.rb:70:in `start'
railties (3.1.0.rc1) lib/rails/commands.rb:54
railties (3.1.0.rc1) lib/rails/commands.rb:49:in `tap'
railties (3.1.0.rc1) lib/rails/commands.rb:49
script/rails:6:in `require'
script/rails:6
答案 0 :(得分:1)
看起来你正在使用Rails 3.1中尚不支持的New Relic:http://support.newrelic.com/help/discussions/support/7114-rails-31-and-new-relic
答案 1 :(得分:0)
我没有New Relic(或silent-postgres)问题,但我们在某些时候对日志方法进行了别名。
如果以上答案没有帮助,请浏览一下,看看你或者你的宝石/插件是否正在包装ActiveRecord适配器的“log”方法。
我使用pry通过捕获异常,删除“binding.pry”并转储“show-method log”来调试它