Setting Custom URL and Paths for Paperlip Attachments in Rails
By default the path and location of storing file by PaperClip are
:url => "/system/:attachment/:id/:style/:basename.:extension" :path => ":rails_root/public/system/:attachment/:id/:style/:basename.:extension"
which appears to be like
When we need to change this path, by default it can be changed only to
but what if we need to change it to look more like our routes
this is feature which doesn’t work by default for paperclip. But there is a little hack available for this like mentioned here at stackoverflow.
Add an initializer paperclip_default_url_fix.rb
<div class='bogus-wrapper'><notextile><figure class='code'><figcaption><span>paperclip_default_url_fix.rb </span></figcaption>
1 2 3 4 5 6 7 8 9 10 11 12
Now we can create any path and url to save and access attachment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15