Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply Rails controller filter to all controllers of a particular namespace?

Tags:

I have a bunch of controllers in a namespace Foo. I'd like to apply a before_filter 'require_user' to all of them, but not to other controllers, that do not belong to Foo namespace.

Is there any way to accomplish this besides explicitly invoking a before_filter method in each controller?

like image 730
snitko Avatar asked Sep 09 '09 21:09

snitko


1 Answers

You could have a FooController class which includes the before_filter and then use that as the base class for all controllers in that namespace.

like image 121
Shadwell Avatar answered Oct 11 '22 21:10

Shadwell