# Before\_filter question

**URL:** <https://www.ruby-forum.com/t/before-filter-question/132612>\
**Category:** Rails\
**Created:** [March 21, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/before-filter-question/132612 "2008-03-21T21:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [March 21, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/before-filter-question/132612/1 "2008-03-21T21:08:35Z")

</div>

Hi-

So I am using before\_filter to manage authentication on my site. I  
see that you can add before\_filter to a controller to restrict access  
to all methods in that controller.

Is it possible to limit access to a specified set of actions, instead  
of the whole controller?

Thanks!

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [March 21, 2008, 9:17pm UTC](https://www.ruby-forum.com/t/before-filter-question/132612/2 "2008-03-21T21:17:15Z")

</div>

pete wrote:

> Hi-
> 
> So I am using before\_filter to manage authentication on my site. I  
> see that you can add before\_filter to a controller to restrict access  
> to all methods in that controller.
> 
> Is it possible to limit access to a specified set of actions, instead  
> of the whole controller?
> 
> Thanks!

You mean like?

class UsersController \< ApplicationController  
before\_filter :login\_required, :except =\> [:index, :show]  
before\_filter :check\_administrator\_role, :only =\> [:new, :edit,  
:create, :update]

---

<div class="post-metadata">

**Author:** ![pete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pete](https://www.ruby-forum.com/u/pete)\
**Post date:** [March 21, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/before-filter-question/132612/3 "2008-03-21T21:18:34Z")

</div>

Exactly, thank you!
