# How to allow only the owner of the uploaded file(s) to access these file(s)

**URL:** <https://www.ruby-forum.com/t/how-to-allow-only-the-owner-of-the-uploaded-file-s-to-access-these-file-s/144944>\
**Category:** Rails\
**Created:** [August 4, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/how-to-allow-only-the-owner-of-the-uploaded-file-s-to-access-these-file-s/144944 "2008-08-04T16:10:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [August 4, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/how-to-allow-only-the-owner-of-the-uploaded-file-s-to-access-these-file-s/144944/1 "2008-08-04T16:10:34Z")

</div>

Hello!

I am allowing my users to upload files, and it will end up in public  
\videos.

How can I ensure that user A can see only his files? Is there a plug  
in for this?

Thank You!

---

<div class="post-metadata">

**Author:** ![nik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/6de8d8/32.png) [@nik](https://www.ruby-forum.com/u/nik)\
**Post date:** [August 4, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/how-to-allow-only-the-owner-of-the-uploaded-file-s-to-access-these-file-s/144944/2 "2008-08-04T17:13:58Z")

</div>

assuming everything is setup like this:

Model User:  
has\_many :videos

Model Videos:  
belongs\_to :user

somewhere in the session you have stored the logged in user and can  
access him with a method like current\_user  
then in you controller:

current\_user.videos.find(params[:id])

or whatever find is necessary
