before_filter and with_scope



I will be speaking on the Rails Recipes Meetup here in Stockholm tomorrow. My topic will be on recipe 28 in Chads excellent book, how you can use with_scope to DRY your code.

Whilst I have looked quite deeply into the subject - it is quite small actually - there is one thing I have yet to find out. Chad mentions that you can use wrap your actions with scoping using a before_filter.

The thing is that the author of the patch for nested scopes provides a plugin to enable just that, but he uses an around filter which utilizes funky metaprogramming to do just that. He has a whole blog entry about it.

I’ve asked twice in the IRC channel without any answer, and I’ve posted a question on the books forum.

Does anybody know if a before_filter can be used?