I’m building a kind of blog system with ruby on rails in my localhost.
I want only authenticated users to be able to see attached images.
Currently only authenticated users can read articles (by ‘devise’), but even non-authenticated users can access to images via urls of them.
When I display a photo uploaded, the url of the image is shown and it’s like this:
http://localhost:3000/system/assets/1/original/meadow.jpg?1306153343
So, what should I do to fix this?
My Environment
Ubuntu 10.04 LTS
Ruby 1.8.7
Rails 3.0.7
Rubygems 1.8.1
devise 1.3.4
paperclip 2.3.11
You need to add a method to download an image using send_file, so that you can check if a user is signed in.
http://api.rubyonrails.org/classes/ActionController/Streaming.html
http://www.therailsway.com/2009/2/22/file-downloads-done-right