# Before\_filter application =\> exclude some other controllers

**URL:** <https://www.ruby-forum.com/t/before-filter-application-exclude-some-other-controllers/121970>\
**Category:** Rails\
**Created:** [December 3, 2007, 2:46pm UTC](https://www.ruby-forum.com/t/before-filter-application-exclude-some-other-controllers/121970 "2007-12-03T14:46:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 3, 2007, 2:46pm UTC](https://www.ruby-forum.com/t/before-filter-application-exclude-some-other-controllers/121970/1 "2007-12-03T14:46:31Z")

</div>

Hello again,

It’s possible to use before\_filter in the application\_controller, and  
exclude for some methods from other controllers ?

i have a before\_filter in application\_controller that checks if the user  
is logged, if the time hasn’t expired, … and I want to exclude some  
methods of this check, like the login. This ‘login’ belongs to other  
controller.

I can put those before\_filter in every control that will need it, but  
all of my controls need it, so I prefer to put it in the  
application\_controller.

thanks,

raimon

ps. this doesn’t work

before\_filter (:session\_expiry =\> :except ) {|login\_controller|}

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 3, 2007, 5:00pm UTC](https://www.ruby-forum.com/t/before-filter-application-exclude-some-other-controllers/121970/2 "2007-12-03T17:00:39Z")

</div>

Add this to your login\_controller:

skip\_before\_filter :session\_expiry

-Bill

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [December 3, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/before-filter-application-exclude-some-other-controllers/121970/3 "2007-12-03T17:16:18Z")

</div>

William P. wrote:

> Add this to your login\_controller:
> 
> skip\_before\_filter :session\_expiry
> 
> -Bill

thanks, sounds more logical …

regards,

raimon
