Note that if I use the default Paperclip :path (i.e. not setting this
attribute and files going to public/system), everything is fine. This
question is to do with setting an alternative path.
I have a model using paperclip for a file with a custom path:
has_attached_file :tu_raw_bill_csv, :path =>
The uploaded document gets saved correctly to the set path above, i.e.:
However, the problem I am having is that when I present a link to the
in the view (model#tu_raw_bill_csv.url), it holds the following url:
As well, if I interrogate my model for the file url and path I get this
which is clearly not where the file got saved:
Then, of course when I navigate the link, I get a routing error, and
I did not, the file would not be there.
So really two questions:
(1) Why is paperclip saving the wrong path (this looks like the default
paperclip path)? Am I missing an attribute declaration? I am reading the
information on interpolations but don’t see where I am going wrong.
(2) As for accessing files, locally or anywhere I guess I can either go
through a controller (for increased security) or provide the direct url
(using S3 I found it seamless to provide the direct url, assuming I did
care so much about security). Would going through a controller action be
best pratice if I want to protect the file from non-logged in access?
if I want to use an alternative path no in ‘public’ then how to go about
thei without going through a controller action? I guess I could symlink
datastore to within the public directiory — would this be the best way