
This was a tricky error to debug because it was only seen sporadically. Eventually we saw that the exception was, generally, only happening when users were uploading large files. (10mb or above)
I’m still not sure as to the root cause of the problem. I suspect it has to do with the combination of plugins we are running (including filecolumn). If this was happening in vanilla Rails it would be a serious bug that the core team would’ve addressed by now.
First I was able to consistently repo the issue by uploading a 10mb file as an attachment. If you don’t have any lying around I found some test files here at cachefly.
The problem occurs when these file data objects (class Tempfile) are left in the params hash for the next session. Clearing out the Tempfile from the params hash prevents this.
What I’ve got now in application.rb:
after_filter :clear_filedata_params
def clear_filedata_params
params.each_pair do |k, v|
params.delete(k) if v.is_a?(Tempfile) || v.is_a?(File)
end
end
helper_method :clear_filedata_params
So from now on, if you’re passing a file data object as a root param, i.e. {:file_data => #File<...>}, this will automatically be cleared from params and should work ok.
If you pass it in as, {:foo => {:file_data => #File<...>}}, you’ll need to clear it out manually, since the after_filter won’t catch it. (Or if you know how to flatten a Ruby Hash easily, let me know!) In this case you could simply do a “params.delete(:foo)”.
Entire Stacktrace (for the google bot):
TypeError (singleton can't be dumped):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:83:in `dump'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:83:in `marshal'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:137:in `marshal_data!'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:333:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:333:in `callback'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:330:in `each'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:330:in `callback'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:241:in `create_or_update'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1545:in `save_without_validation'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/validations.rb:752:in `save_without_transactions'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:129:in `save'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:95:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:121:in `transaction'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:129:in `save'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:311:in `update'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:867:in `silence'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:311:in `update'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/session/active_record_store.rb:318:in `close'
/usr/local/lib/ruby/1.8/cgi/session.rb:324:in `close'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1184:in `close_session'
/usr/local/l







