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

Hello,

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/ public/:class/:attachment/:id/:style_:basename.:extension"

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/ public/:class/:attachment/:id/:style_:basename.:extension" :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.

love-n-peace, @shaan 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/iepngfix.htc" with {:method=>:get}):.

I am presently working on a single computer.

love-n-peace, @shaan '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:

http://patshaughnessy.net/2009/5/16/paperclip-sample-app-part-2-downloading-files-through-a-controller

- pat http://patshaughnessy.net

Hello Pat,

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

love-n-peace, @shaan 'Aal izz well' :slight_smile: