This project is archived and is in readonly mode.
2.3 Session Storing an ActiveRecord object crashes with nil.include? and undefined class/module
Reported by George Chatzigeorgiou | February 17th, 2009 @ 03:32 PM | in 2.x
I have a line of code in a controller that stores an active record object in the session
session[:cart] = @order
With 2.2.2 this works perfectly ok, but with 2.3 I get an "nil.include?" error that has to do with skip_time_zone_conversion_attributes. I patched that and then I got the "undefined class/Module Order" error.
It makes no difference which session type I'm using, both CookieStore and ActiveRecord store crash.
Below is the stack trace for the first error:
Order Columns (2.8ms) SHOW FIELDS FROM orders
/!\
FAILSAFE /!\ Tue Feb 17 15:41:17 +0200 2009 Status: 500 Internal
Server Error You have a nil object when you didn't expect it! You
might have expected an instance of Array. The error occurred while
evaluating nil.include?
/home/bandito/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'
/home/bandito/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods'
/home/bandito/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:71:in `each'
/home/bandito/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
/home/bandito/.gem/ruby/1.8/gems/activerecord-2.3.0/lib/active_record/attribute_methods.rb:350:in `respond_to?'
/home/bandito/.gem/ruby/1.8/gems/activesupport-2.3.0/lib/active_support/message_verifier.rb:36:in `dump'
/home/bandito/.gem/ruby/1.8/gems/activesupport-2.3.0/lib/active_support/message_verifier.rb:36:in `generate'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/session/cookie_store.rb:154:in `marshal'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/session/cookie_store.rb:100:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/failsafe.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:83:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/cgi_process.rb:44:in `dispatch_cgi'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:79:in `dispatch_cgi'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:29:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
and after patching create_time_zone_conversion_attribute?
def create_time_zone_conversion_attribute?(name, column)
time_zone_aware_attributes && (!skip_time_zone_conversion_for_attributes || skip_time_zone_conversion_for_attributes.include?(name.to_sym)) && [:datetime, :timestamp].include?(column.type)
end
Status: 500 Internal Server Error undefined class/module Order
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/session_store.rb:67:in `dump'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/session_store.rb:67:in `marshal'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/session_store.rb:123:in `marshal_data!'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:178:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:178:in `evaluate_method'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:166:in `call'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:93:in `run'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:92:in `each'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:92:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:92:in `run'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.0/lib/active_support/callbacks.rb:276:in `run_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/callbacks.rb:316:in `callback'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/callbacks.rb:221:in `create_or_update'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:2532:in `save_without_validation'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/validations.rb:1009:in `save_without_dirty'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/dirty.rb:79:in `save_without_autosave_associations'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/autosave_association.rb:147:in `save_without_transactions'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:229:in `send'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:182:in `transaction'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:196:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/transactions.rb:196:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/session_store.rb:301:in `set_session'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/base.rb:1454:in `silence'
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.0/lib/active_record/session_store.rb:298:in `set_session'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/session/abstract_store.rb:116:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/failsafe.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/rack_ext/lock.rb:15:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:83:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/cgi_process.rb:44:in `dispatch_cgi'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:79:in `dispatch_cgi'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.0/lib/action_controller/dispatcher.rb:29:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Comments and changes to this ticket
-
csnk May 18th, 2011 @ 08:18 AM
- Importance changed from to
We are the professional shirts manufacturer, shirts supplier, shirts factory, custom shirts.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>