Forum: Ruby on Rails name space and before filter

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eecd295cdec2454c66e2015036a39408?d=identicon&s=25 Scott Nj (scottnj)
on 2008-11-28 17:08
(Received via mailing list)
is it possible to have a before filter apply to all controllers in a
name space, or do you have to do it separate for each individual
controller. for example, an admin name space with a require_admin
before filter.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-28 17:20
(Received via mailing list)
On Nov 28, 4:07 pm, scott <scot...@gmail.com> wrote:
> is it possible to have a before filter apply to all controllers in a
> name space, or do you have to do it separate for each individual
> controller. for example, an admin name space with a require_admin
> before filter.

easiest way is to have those controllers inherit from some common
controller.

Fred
2d8132658d56e51f19ace1c68e48b6aa?d=identicon&s=25 Thorsten Mueller (thorsten)
on 2008-11-28 17:22
(Received via mailing list)
Freds tip is good, if you don't want to do it,
you can test for the name space in the filter like:
request.path.starts_with?('/admin')
Eecd295cdec2454c66e2015036a39408?d=identicon&s=25 Scott Nj (scottnj)
on 2008-11-28 20:38
(Received via mailing list)
thanks fred, that is a clean and easy solution.

On Nov 28, 11:20 am, Frederick Cheung <frederick.che...@gmail.com>
This topic is locked and can not be replied to.