markevans/dragonfly — Issue #146: to_file raises copy errors for certain url formats
Author: avand
Created: 2011-11-21 17:06:45+00:00
State: open

Related to this StackOverflow thread:

http://stackoverflow.com/questions/7096597/dragonfly-gem-default-images

If you try and generate an image from a file and the `url_format` as configured in the Dragonfly app calls for subdirectories, you'll get a `Errno::ENOENT: No such file or directory` error:

``` ruby
Dragonfly[:images].configure do |config|
config.allow_fetch_file = true
config.url_format = '/:job/:basename.:format'
end

job = Dragonfly[:images].fetch_file Rails.root.join("public", "images", "default.jpg")
job.to_file "#{Rails.root}/tmp#{@job.url}"
# => raises Errno::ENOENT: No such file or directory
```

This is because the subdirectory (`:job`) as specified in the URL format doesn't exist.