# Can I change the order for before\_filter's between applicati

**URL:** <https://www.ruby-forum.com/t/can-i-change-the-order-for-before-filters-between-applicati/75778>\
**Category:** Rails\
**Created:** [November 13, 2006, 11:32am UTC](https://www.ruby-forum.com/t/can-i-change-the-order-for-before-filters-between-applicati/75778 "2006-11-13T11:32:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [November 13, 2006, 11:32am UTC](https://www.ruby-forum.com/t/can-i-change-the-order-for-before-filters-between-applicati/75778/1 "2006-11-13T11:32:29Z")

</div>

Hi,

Can I change the order for before\_filter’s between application.rb  
filters &  
another filters from another controller that inherits from  
“ApplicationController” ???

For example I have 3 before\_filters in application.rb, and these seem to  
be  
handled before the before\_filter that I have in another specific  
controller  
that inherits from ApplicationController (in this particular case the  
specific controller is part of a plugin, hence is in the vendor  
directory).  
I really want the plugin vendors controller before\_filter to fire before  
the  
ones in the application.rb.

Tks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [November 13, 2006, 12:04pm UTC](https://www.ruby-forum.com/t/can-i-change-the-order-for-before-filters-between-applicati/75778/2 "2006-11-13T12:04:34Z")

</div>

never used it, but rails docs got this:

prepend\_before\_filter :yourfilteraction

from the docs:  
"Using before\_filter and after\_filter appends the specified filters to  
the existing chain. That’s usually just fine, but some times you care  
more about the order in which the filters are executed. When that’s  
the case, you can use prepend\_before\_filter and prepend\_after\_filter.  
Filters added by these methods will be put at the beginning of their  
respective chain and executed before the rest. For example: "

maybe that works, not sure though.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [November 14, 2006, 12:00pm UTC](https://www.ruby-forum.com/t/can-i-change-the-order-for-before-filters-between-applicati/75778/3 "2006-11-14T12:00:19Z")

</div>

Tks - this worked - wonder what would happen however if you had multiple  
plugins, including vendor plugins. How would you control the order  
then?
