Answer the question
In order to leave comments, you need to log in
How to properly organize the storage of user files on the server?
Hello.
I use paperclip to upload files to the server. At the same time, I expect that there will be a lot of files, so I want to somehow organize the ways to save files. I tried doing like this:
has_attached_file :file, url: '/downloads/:id/:basename.::extension'
has_attached_file :file, url: '/downloads/:category_id/:id/:basename.::extension'
Answer the question
In order to leave comments, you need to log in
1. In initializer add:
Paperclip.interpolates :category_id do |attachment, style|
attachment.instance.category_id.to_s
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question