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?
views:
73answers:
2
A:
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
2010-08-23 18:13:22
A:
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
2010-08-23 18:23:30