P
P
Perzh2014-04-16 21:00:30
Ruby on Rails
Perzh, 2014-04-16 21:00:30

How to organize the download of a file from the server (paperclip)?

Hello.
Playing around with RoR. I'm trying paperclip to upload custom files, but I don't know how to share those files. I do something like this:

<%= link_to 'Download', @object.file.url %>
#file - поле из paperclip

When I try to follow the link, I get a RoutingError. Can you please tell me how to organize the ability to download a file from the server? Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IvanN777, 2014-11-08
@IvanN777

If the file uploaded is attached to a model, eg as an attribute called avatar, then you can create a link like:
<%= link_to "Download", model.avatar.url(:original, false) %>
Replace avatar with the name of your attribute.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question