开发者

Rails 3.1 - Postgres - Works in Console but not Webrick

We have a large, complex rails app we're beginning to migrate from 2.8 to 3.1

Console finally starts, and User.last returns the expected value.

However, when we fire up the server, User.last ends up causing an argument error deep in the postgresql adapter.

**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:开发者_StackOverflow社区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


It looks like you're using New Relic, which isn't yet supported in Rails 3.1: http://support.newrelic.com/help/discussions/support/7114-rails-31-and-new-relic


I did not have a New Relic (or silent-postgres) problem, but we were aliasing the log method at some point.

if the above answers don't help, take a look around and see if you, or your gems/plugins are wrapping the ActiveRecord adapter's "log" method.

I debugged this using pry by catching the exception, dropping a "binding.pry" and dumping "show-method log"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜