jnicklas/carrierwave — Issue #503: Errno::ENOENT when using extension_white_list
Author: Eleo
Created: 2011-10-25 21:16:10+00:00
State: open

I'm running into this issue when I use `extension_white_list`. Without an `extension_white_list` method defined in my Uploader, everything works fine; however, trying to do it gives me this:

````
Errno::ENOENT - No such file or directory - /home/eleo/Projects/yellowcake/public/random/yellowcake.jpg:
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/carrierwave-7ca72b689df9/lib/carrierwave/sanitized_file.rb:157:in `initialize'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/carrierwave-7ca72b689df9/lib/carrierwave/sanitized_file.rb:157:in `open'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/bundler/gems/carrierwave-7ca72b689df9/lib/carrierwave/sanitized_file.rb:157:in `read'
/home/eleo/Projects/yellowcake/models/upload.rb:63:in `hash_file_digest'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:395:in `_run_validation_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:42:in `block in run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `run_cascading_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:41:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations.rb:179:in `valid?'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/validations.rb:68:in `valid?'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/validations/associated.rb:36:in `block in validate_each'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/validations/associated.rb:32:in `collect'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/validations/associated.rb:32:in `validate_each'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validator.rb:153:in `block in validate'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validator.rb:150:in `each'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validator.rb:150:in `validate'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:302:in `_callback_before_23'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:395:in `_run_validate_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:42:in `block in run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `run_cascading_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:41:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations.rb:212:in `run_validations!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:399:in `_run_validation_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:42:in `block in run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:67:in `run_cascading_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/callbacks.rb:41:in `run_callbacks'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations.rb:179:in `valid?'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/validations.rb:68:in `valid?'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/activemodel-3.1.1/lib/active_model/validations.rb:187:in `invalid?'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence/insertion.rb:23:in `block in prepare'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence/insertion.rb:22:in `tap'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence/insertion.rb:22:in `prepare'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence/operations/insert.rb:26:in `persist'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence.rb:44:in `insert'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/persistence.rb:149:in `upsert'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/relations/referenced/many.rb:93:in `block in create'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/relations/referenced/many.rb:92:in `tap'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/mongoid-2.3.2/lib/mongoid/relations/referenced/many.rb:92:in `create'
/home/eleo/Projects/yellowcake/app/controllers/posts.rb:5:in `block (2 levels) in '
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:569:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:569:in `block in route'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:51:in `[]'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:51:in `block (3 levels) in process_destination_path'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:788:in `route_eval'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:51:in `block (2 levels) in process_destination_path'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:51:in `catch'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:51:in `block in process_destination_path'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:25:in `instance_eval'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:25:in `process_destination_path'
(eval):16:in `block (2 levels) in inject_root_methods'
(eval):6:in `catch'
(eval):6:in `block in inject_root_methods'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/http_router-0.10.2/lib/http_router/node/root.rb:79:in `[]'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/http_router-0.10.2/lib/http_router.rb:119:in `block in call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/http_router-0.10.2/lib/http_router.rb:119:in `catch'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/http_router-0.10.2/lib/http_router.rb:119:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:910:in `route!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/application/routing.rb:900:in `dispatch!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `block in call!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `block in invoke'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `catch'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `invoke'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `call!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:692:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/reloader.rb:250:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/logger.rb:306:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:21:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:195:in `context'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/session/abstract/id.rb:190:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `block in call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:1403:in `synchronize'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/router.rb:83:in `block in call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/router.rb:76:in `each'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/router.rb:76:in `call'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/connection.rb:84:in `block in pre_process'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/handler/thin.rb:13:in `run'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/rack-1.3.5/lib/rack/server.rb:265:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/server.rb:45:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/server.rb:34:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/server.rb:12:in `run!'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/cli/adapter.rb:7:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/lib/padrino-core/cli/base.rb:24:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/gems/padrino-core-0.10.5/bin/padrino:9:in `'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/bin/padrino:19:in `load'
/home/eleo/.rvm/gems/ruby-1.9.3-preview1/bin/padrino:19:in `

'
````

When I look in my application's temporary directory I see no uploaded files

I'm using Padrino, Mongoid with carrierwave-mongoid, and Thin as my development server. What I'm seeing from my POST params is:

````
{"upload"=>{:filename=>"yellowcake.jpg", :type=>"image/jpeg", :name=>"post[upload]", :tempfile=>#, :head=>"Content-Disposition: form-data; name=\"post[upload]\"; filename=\"yellowcake.jpg\"\r\nContent-Type: image/jpeg\r\n"}, "comment"=>"", "author"=>""}
````

I'm thinking the failure stems from the tempfile having the filename `RackMultipart20111025-2804-1nfjbx4`, which has no extension and is thus rejected by Carrierwave. Anything I can do? Should I forgo `extension_white_list` and create my own validation based on extension?