# Constructing current\_user.recipes for administrators?

**URL:** <https://www.ruby-forum.com/t/constructing-current-user-recipes-for-administrators/154192>\
**Category:** Rails\
**Created:** [November 26, 2008, 10:14am UTC](https://www.ruby-forum.com/t/constructing-current-user-recipes-for-administrators/154192 "2008-11-26T10:14:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 26, 2008, 10:14am UTC](https://www.ruby-forum.com/t/constructing-current-user-recipes-for-administrators/154192/1 "2008-11-26T10:14:16Z")

</div>

I’m using the restful\_authentication’s current\_user. So to find a user’s  
recipes, I use:

current\_user.recipes

I want the admin (I have an “admin” column in the users table) to view  
all recipes. I’m doing this right now, but think its too verbose:

@recipes = current\_user.admin? ? Recipe.all : current\_uesr.recipes

Is there a more efficient way to have the admin view all recipes (and  
non-admin only to view their own recipes) instead of doing the above?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [November 27, 2008, 7:52am UTC](https://www.ruby-forum.com/t/constructing-current-user-recipes-for-administrators/154192/2 "2008-11-27T07:52:24Z")

</div>

You might think of an index all that is accessible only to admin.

before\_filter :check\_admin\_role, :only =\> [:index]

Rick

On Nov 25, 11:14 pm, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
