# Extending before\_filter scope to entire controllers?

**URL:** <https://www.ruby-forum.com/t/extending-before-filter-scope-to-entire-controllers/84163>\
**Category:** Rails\
**Created:** [February 1, 2007, 10:49pm UTC](https://www.ruby-forum.com/t/extending-before-filter-scope-to-entire-controllers/84163 "2007-02-01T22:49:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 1, 2007, 10:49pm UTC](https://www.ruby-forum.com/t/extending-before-filter-scope-to-entire-controllers/84163/1 "2007-02-01T22:49:40Z")

</div>

All,

I have my check\_authentication and login stuff in my base  
ApplicationController in application.rb (I realize that these  
could/should be in another controller). What’s nice about this setup is  
that I can apply authorization checking to my entire app. just by  
providing a before\_filter in ApplicationController.

However, now I’m writing a controller whose methods allow users to  
request a login, which obviously should be not checking for  
authentication. But I can only “except” methods by name, not by  
controller membership.

I got around this by overriding the check\_authentication method (defined  
in ApplicationController) to do nothing in this particular controller.  
This works, but feels kludgy.

Has any thought been given to allowing before\_filter :only and :except  
arrays to accept controller names as well as individual actions. Then I  
could just “except” this controller from the before\_filter and still get  
the benefit of defining the before\_filter only once in  
ApplicationController.

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 1, 2007, 11:16pm UTC](https://www.ruby-forum.com/t/extending-before-filter-scope-to-entire-controllers/84163/2 "2007-02-01T23:16:20Z")

</div>

You can skip the before\_filter by adding this to your controller:

skip\_before\_filter :check\_authentication

:only and :except work too, so you can apply it to specific actions in  
that controller.

See “Filter chain skipping” here [Peak Obsession](http://api.rubyonrails.com/classes/)  
ActionController/Filters/ClassMethods.html

On Feb 1, 3:49 pm, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 1, 2007, 11:49pm UTC](https://www.ruby-forum.com/t/extending-before-filter-scope-to-entire-controllers/84163/3 "2007-02-01T23:49:04Z")

</div>

Wes Bangerter wrote:

> You can skip the before\_filter by adding this to your controller:
> 
> skip\_before\_filter :check\_authentication
> 
> :only and :except work too, so you can apply it to specific actions in  
> that controller.
> 
> See “Filter chain skipping” here [Peak Obsession](http://api.rubyonrails.com/classes/)  
> ActionController/Filters/ClassMethods.html
> 
> On Feb 1, 3:49 pm, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thx! Forgot about that one.
