Changing the :path and :url options of has_attached_file in paperclip


I am using the paperclip plugin to upload images and it works
absolutely fine.

I intend to save my uploaded images to C:\Application_name\public
folder. Accordingly, with some study over the i-net, I changed
the :path option of has_attached_file to -

:path => "C:/Application_name/

Now, the files are being saved to the desired path. However, I need to
understand what should be the corresponding change in the :url option.

I tried everything -

:url => "/:id/:style_:basename.:extension"
:url => "C:/Application_name/
:url => "/public/:class/:attachment/:id/:style_:basename.:extension"

but none of them work. The image couldn't be displayed.

Request, please share any inputs which could help me further to this.

Thanks in advance.

Aal izz well...:slight_smile:

:url => "/:class/:attachment/:id/:style_:basename.:extension"

Basically the same thing as :path, starting at where 'public' leaves off.

Hello Philip,

I have tried this, but unfortunately it has not worked. I can only see
the image file name with a cross icon, but the image can't be seen.
Some additional information - in the log, I can see this error (just
in case it helps):

ActionController::RoutingError (No route matches "/css/"
with {:method=>:get}):.

I am presently working on a single computer.

'Aal izz well' :slight_smile:

Probably you need to add a corresponding route + controller action to
handle the download requests. I wrote a tutorial a while back on this:

- pat

Hello Pat,

It worked out with a charm :slight_smile: Thanks a ton for the solution...

'Aal izz well' :slight_smile: