# How to deal with user rights in the views?

**URL:** <https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891>\
**Category:** Rails\
**Created:** [January 30, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891 "2007-01-30T16:17:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [January 30, 2007, 4:17pm UTC](https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891/1 "2007-01-30T16:17:08Z")

</div>

Hi,  
This is a question about the best way to develop an application with  
different user rights.

According to the user rights, i want to display the same views but with  
small differences (like additional buttons if the user is an admin,  
moderator, etc).

The problem (I think) is that I’ve put a lot of logic in my views (if  
admin  
then… else… etc). is that the best way to deal with user rights in  
the views?

Thanks for your advices.

---

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [January 30, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891/2 "2007-01-30T17:10:58Z")

</div>

look into acts as authenticated plugin. checkout how the admin/user has  
their own view. you can just basiclly take your public view, copy it  
into the admin view and add all the buttons youd like.

Nicolas B. wrote:

> Hi,  
> This is a question about the best way to develop an application with  
> different user rights.
> 
> According to the user rights, i want to display the same views but with  
> small differences (like additional buttons if the user is an admin,  
> moderator, etc).
> 
> The problem (I think) is that I’ve put a lot of logic in my views (if  
> admin  
> then… else… etc). is that the best way to deal with user rights in  
> the views?
> 
> Thanks for your advices.

---

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [January 30, 2007, 7:14pm UTC](https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891/3 "2007-01-30T19:14:33Z")

</div>

Nicolas B. wrote:

> then… else… etc). is that the best way to deal with user rights in  
> the views?
> 
> Thanks for your advices.

You could use helpers.

–  
Jack C.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![budu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b5e925/32.png) [@budu](https://www.ruby-forum.com/u/budu)\
**Post date:** [September 25, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/how-to-deal-with-user-rights-in-the-views/83891/4 "2007-09-25T23:10:44Z")

</div>

some pseudocode:

#view:  
admin\_link\_to { :action =\> delete }

#helper:  
def admin\_link\_to(options)  
if @user.has\_role(‘Admin’) #or however your rights system works …  
link\_to(options)  
end  
end
