Question on Paperclip paths/urls

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 =>

“…/ncc_billing_filestore/:attachment/:id/:style/:filename”

The uploaded document gets saved correctly to the set path above, i.e.:

/system/tu_raw_bill_csvs/7/original/integral_tu_raw_bill_csv.txt?1297787632

However, the problem I am having is that when I present a link to the
file
in the view (model#tu_raw_bill_csv.url), it holds the following url:

http://localhost:3000/system/tu_raw_bill_csvs/7/original/integral_tu_raw_bill_csv.txt?1297787632

As well, if I interrogate my model for the file url and path I get this
url,
which is clearly not where the file got saved:

@billing_run.tu_raw_bill_csv

/system/tu_raw_bill_csvs/7/original/integral_tu_raw_bill_csv.txt?1297787632

Then, of course when I navigate the link, I get a routing error, and
even if
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
not
care so much about security). Would going through a controller action be
the
best pratice if I want to protect the file from non-logged in access?
Also,
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
my
datastore to within the public directiory — would this be the best way
to
do this?

Thanks,

David

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