Topic: view throws 500 randomly, fixed with server restart

I'm rather new to rails and have a problem that I cannot figure out. A particular view is randomly throwing a 500 error: to_json ArgumentError. If I restart the server the problem is fixed immediately. If I don't restart the server it still randomly works, and randomly breaks again.

I'm thinking it has something to do with caching. This is probably not much information to go on, but any help is appreciated.

Here's the controller code:

    records_json = @orders.collect{|order|
      {'orders' => {'id' => order.id,
        'created_at' => order.created_at,
        'billing_first_name' => order.billing_first_name,
        'billing_last_name' => order.billing_last_name,
        'billing_city' => order.billing_city,
        'billing_state' => order.billing_state,
        'billing_zip' => order.billing_zip,
        'total' => order.order_total,
        'shipping_method' => order.shipping_method,
        'first_item' => (order.items.size > 0 ? order.items.first.name : ''),
        'items_count' => order.items.inject(0){|m,i| m + i.quantity}}}
    }.to_json
   
    render :text => %[{"totalRecords":#{Order.count(:all, :include => find_include, :conditions => find_conditions)},
      "recordsReturned":#{@orders.size},
      "startIndex":#{startIndex},
      "sort":"#{order_by}",
      "dir":"#{dir}",
      "records":#{records_json}}]


Here's the trace:

ArgumentError (wrong number of arguments (2 for 1)):
    /app/controllers/admin/orders_controller.rb:45:in `to_json'
    /app/controllers/admin/orders_controller.rb:45:in `dt_list'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1160:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1160:in `perform_action_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:579:in `call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in `perform_action_without_caching'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `passenger_orig_perform_action'
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
    /vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `passenger_orig_perform_action'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/request_handler.rb:65:in `perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:526:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:526:in `process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:568:in `process_without_session_management_support'
    /vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in `sass_old_process'
    /usr/lib/ruby/gems/1.8/gems/haml-3.0.12/lib/sass/plugin/rails.rb:46:in `process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:387:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:156:in `handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:97:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:94:in `synchronize'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:94:in `dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in `dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:11:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/request_handler.rb:50:in `process_request'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/utils.rb:252:in `safe_fork'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:163:in `start'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    /usr/lib/ruby/gems/1.8/gems/passenger-2.2.14/bin/passenger-spawn-server:61

Last edited by gdangler (2010-12-06 19:03:46)