# After\_filter, but not quite

**URL:** <https://www.ruby-forum.com/t/after-filter-but-not-quite/126517>\
**Category:** Rails\
**Created:** [January 18, 2008, 10:32pm UTC](https://www.ruby-forum.com/t/after-filter-but-not-quite/126517 "2008-01-18T22:32:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [January 18, 2008, 10:32pm UTC](https://www.ruby-forum.com/t/after-filter-but-not-quite/126517/1 "2008-01-18T22:32:42Z")

</div>

Dear list,

A client of ours requested a site which has a different background for  
each page(don’t flame me, I just build it). The background depends on  
stuff I pull from the DB. I planned on using an after\_filter to set an  
instance variable containing the background. Can’t do it in a before  
filter as the background depends on stuff that happens in the actual  
action.

But, as I figured out and in retrospect it makes perfect sense, the  
after\_filter is ran after the action is already rendered. No good for  
me.

So my question really is; how can I made a method which is ran after  
all actions?

With kind regards,  
Harm

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [January 19, 2008, 1:31am UTC](https://www.ruby-forum.com/t/after-filter-but-not-quite/126517/2 "2008-01-19T01:31:32Z")

</div>

you could override render().

def render(\*args)  
some\_after\_filter()  
super(args)  
end

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [January 19, 2008, 11:00am UTC](https://www.ruby-forum.com/t/after-filter-but-not-quite/126517/3 "2008-01-19T11:00:44Z")

</div>

Thats what I came up with last night(sleeping is overrated)! I think  
I’ll implement that. Thanks a lot!

On Jan 19, 1:31 am, Keynan P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
