I'm using Paperclip for letting users upload photos to my app. Then, I'm saving the photos in /public/photos
. Now, I want the photos being accessible just for some users. How can I set this permission system up?
Asked
Active
Viewed 888 times
1

Erik Escobedo
- 2,793
- 24
- 42
2 Answers
0
First, I would recommend not saving your photos to your public folder, but rather some other folder even outside of your app directory.
Second, you can attribute your Photo model to belong_to 'some' users. Not sure what 'some' is in your description. But from then, you can in your controller, only pull photos from the Photo model that your current_user should see.

Trip
- 26,756
- 46
- 158
- 277
0
Definitely move the photos out of public/
, then you can use send_file
in a controller action to display the photos instead.
I briefly skimmed over this blog post, it looked pretty good:
http://harrylove.org/2008/12/22/protected-file-downloads-with-ruby-on-rails-and-paperclip.html

cam
- 14,192
- 1
- 44
- 29
-
2The above link is dead (404). – Arne L. Aug 09 '13 at 17:12