# Problem with mixins and filters

**URL:** <https://www.ruby-forum.com/t/problem-with-mixins-and-filters/171275>\
**Category:** Rails\
**Created:** [June 29, 2009, 10:17pm UTC](https://www.ruby-forum.com/t/problem-with-mixins-and-filters/171275 "2009-06-29T22:17:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [June 29, 2009, 10:17pm UTC](https://www.ruby-forum.com/t/problem-with-mixins-and-filters/171275/1 "2009-06-29T22:17:04Z")

</div>

Hi all,

I am stumped with the following problem:

- A module, which is mixed into a controller, defines two methods, ‘a’  
and ‘b’
- ‘a’ calls ‘b’
- ‘b’ might be overriden in the controller
- when ‘a’ is called as a ‘before\_filter’, it always calls the version  
of ‘b’ defined in the mixin module, regardless of whether the controller  
defines its own ‘b’.
- when ‘a’ is called as an action, it correctly invokes the ‘right’  
version of ‘b’.

For example:

module A  
def a  
b  
end

def b  
puts “A.b called”  
end  
end

class FooController \< ApplicationController  
include A

before\_filter :a

def b  
puts “C.b called”  
end  
end

I’m at a loss. Could anyone toss me a clue? Thanks!

Brian

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [June 29, 2009, 10:41pm UTC](https://www.ruby-forum.com/t/problem-with-mixins-and-filters/171275/2 "2009-06-29T22:41:50Z")

</div>

Brian H. wrote:

Never mind. I had another problem which mislead me; the example I gave  
works perfectly once I correct the other problem.

> Hi all,
> 
> I am stumped with the following problem:
> 
> - A module, which is mixed into a controller, defines two methods, ‘a’  
> and ‘b’
> - ‘a’ calls ‘b’
> - ‘b’ might be overriden in the controller
> - when ‘a’ is called as a ‘before\_filter’, it always calls the version  
> of ‘b’ defined in the mixin module, regardless of whether the controller  
> …
