"can't dump File" error

Hi all,

I’m using attachment_fu to upload files using a pretty standard
configuration, and have come across the following error. When I upload
a file (fill in a form and submit to a “create” action), I get the
error:

TypeError (can’t dump File):

The browser then renders:

Status: 500 Internal Server Error
can’t dump File

The upload code still works successfully, and the photos are shown
when the page is reloaded. I’m not sure, but I think this may be
related to changing session storage from the default
to :active_record_store. A full stack trace is below. Has anyone else
come across this issue?

Many thanks,
Adam

TypeError (can’t dump File):
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session/active_record_store.rb:83:in dump' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session/active_record_store.rb:83:inmarshal’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session/active_record_store.rb:136:in marshal_data!' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ callbacks.rb:307:insend’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:307:in callback' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ callbacks.rb:304:ineach’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
callbacks.rb:304:in callback' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ callbacks.rb:212:increate_or_update’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1972:in save_without_validation' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ validations.rb:934:insave_without_transactions’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in save' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/database_statements.rb:66:intransaction’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:80:in transaction' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ transactions.rb:100:intransaction’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in save' /var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ transactions.rb:120:inrollback_active_record_state!’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
transactions.rb:108:in save' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session/active_record_store.rb:310:inupdate’
/var/lib/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1198:in silence' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session/active_record_store.rb:310:inupdate’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
session/active_record_store.rb:317:in close' /usr/lib/ruby/1.8/cgi/session.rb:324:inclose’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:1247:in close_session' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:1292:inprocess_cleanup_without_flash’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
flash.rb:173:in process_cleanup_without_session_management_support' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session_management.rb:133:inprocess_cleanup_without_components’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
components.rb:161:in process_cleanup' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:532:inprocess_without_filters’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:685:in process_without_session_management_support' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session_management.rb:123:inprocess’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:388:in process' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:171:inhandle_request’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in dispatch' /var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:126:indispatch_cgi’
/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in dispatch' /var/lib/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel/rails.rb: 76:inprocess’
/var/lib/gems/1.8/gems/mongrel-1.1.3/bin/…/lib/mongrel/rails.rb:
74:in synchronize' /var/lib/gems/1.8/gems/mongrel-1.1.3/bin/../lib/mongrel/rails.rb: 74:inprocess’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:159:in
process_client' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:158:ineach’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:158:in
process_client' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:285:inrun’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:285:in
initialize' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:285:innew’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:285:in run' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:268:ininitialize’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:268:in new' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:268:inrun’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel/configurator.rb:
282:in run' /var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel/configurator.rb: 281:ineach’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel/configurator.rb:
281:in run' /var/lib/gems/1.8/gems/mongrel-1.1.3/bin/mongrel_rails:128:inrun’
/var/lib/gems/1.8/gems/mongrel-1.1.3/lib/mongrel/command.rb:212:in
run' /var/lib/gems/1.8/gems/mongrel-1.1.3/bin/mongrel_rails:281 /var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:489:inload’
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:489:in load' /var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:489:in load' /var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/servers/mongrel.rb: 64 /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in require' /var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:496:inrequire’
/var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:342:in new_constants_in' /var/lib/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:496:inrequire’
/var/lib/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:inrequire’
./script/server:3
-e:2:in `load’
-e:2

I’m getting the same thing with the memcache session and another
person(in another thread) has had this problem as well.
Mike Kohout

Hi Michael,

I found a solution to this. The problem was that I was trying to store
the params hash in either the flash or session hash (I forget which),
with the idea that I could use this information to redirect the user
in a particular way. However, when I uploaded a file, the params hash
would include a File object (e.g. :filedata => <#FileXXX>. You can’t
store a File object in the session storage, hence the error.

Hope this helps,
Adam

hmm…I was getting this behavior from regular ol attachment_fu. To
solve it, I just rolled my own file code.

But thanks for the update!

Michael K. wrote in post #693402:

hmm…I was getting this behavior from regular ol attachment_fu. To
solve it, I just rolled my own file code.

But thanks for the update!

Pls can you describe how you got around this issue?

Thanks.
Taiwo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs