# Protect my admin namespace

**URL:** <https://www.ruby-forum.com/t/protect-my-admin-namespace/144144>\
**Category:** Rails\
**Created:** [July 25, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/protect-my-admin-namespace/144144 "2008-07-25T21:16:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 25, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/protect-my-admin-namespace/144144/1 "2008-07-25T21:16:14Z")

</div>

Hi all.

I’ve an admin namespace in my app with some controllers.

What’s the best approach in order to login protect all of them?  
I’m thinking about using before\_filter, but I can forget to add it to  
an new controller, in the future.  
Googling for it, I’ve found this:  
[http://rpheath.com/posts/302-directory-based-authentication-in-rails](http://rpheath.com/posts/302-directory-based-authentication-in-rails)

As I’ve read in the article’s comments, I could use an admin  
superclass. But I can forget to inherits from it too.

So, my question is: what’s the best approach to my problem?  
An Module? Superclass? before\_filter?

Thank you very much and sorry for my poor English.

Davi V.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 25, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/protect-my-admin-namespace/144144/2 "2008-07-25T22:56:06Z")

</div>

Restful authentication plugin

Create a admin/base\_controller

with before\_filter :login\_required

And inherit from this controller class Admin::BooksController \<  
Admin::BaseController

You only need to remember to add the inheritance in new admin  
controllers…

done

This is how I have seen it done, and how I do it myself.
