# How does Rails implement filters?

**URL:** <https://www.ruby-forum.com/t/how-does-rails-implement-filters/143332>\
**Category:** Rails\
**Created:** [July 17, 2008, 2:29pm UTC](https://www.ruby-forum.com/t/how-does-rails-implement-filters/143332 "2008-07-17T14:29:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [July 17, 2008, 2:29pm UTC](https://www.ruby-forum.com/t/how-does-rails-implement-filters/143332/1 "2008-07-17T14:29:41Z")

</div>

Hi,

I got to thinking this morning about filters and how they are actually  
implemented. If I was gonna implement it, I’d be tempted to do  
something like this:

class Base

def perform\_action  
action\_name  
if self.class.responds\_to?(action\_name)  
run\_before\_filters  
run\_around\_filters { send(action\_name) }  
run\_after\_filters  
else  
# do other things  
end  
end

end

Now I see something like that in action\_controller/base.rb, but I see  
no mention of filters. It just calls send(action\_name). Where do the  
filters come in?

Thanks,  
Ryan

---

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [July 17, 2008, 2:35pm UTC](https://www.ruby-forum.com/t/how-does-rails-implement-filters/143332/2 "2008-07-17T14:35:33Z")

</div>

On 17 Jul 2008, at 13:28, Ryan wrote:

> Now I see something like that in action\_controller/base.rb, but I see  
> no mention of filters. It just calls send(action\_name). Where do the  
> filters come in?

Look in filters.rb  
It aliases perform\_action

Fred
