# Namespaces for admin fucntionality, worth the effort?

**URL:** <https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282>\
**Category:** Rails\
**Created:** [October 6, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282 "2008-10-06T22:31:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 6, 2008, 10:31pm UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/1 "2008-10-06T22:31:05Z")

</div>

Hi,

I’m currently having the admin part of one of my apps accessible by pure  
username and password + role management checking.

I was planning to add namespaces for it. Then I came accross this (a bit  
old but still…):  
[http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails](http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails)

"Putting Controllers in Namespaces

This is really more trouble than itâ€™s worth. You run into all sorts of  
crazy errors if you do this and youâ€™ll be confused and frustrated.  
Youâ€™ll then ask other people about it and theyâ€™ll either blow you off  
for using namespaces with controllers or procede to get confused and  
frustrated as well. Then youâ€™ll say, â€œI with I had listened to Kevin and  
Chrisâ€. If you want /admin/some\_controller as an URL thatâ€™s fine. Use  
the routing thatâ€™s built into rails."

I’ve used namespaces for admin before and actually it can create  
confusion. On the other hand using a common controller with some extra  
is\_admin? checks can be a bit ugly. I know it all depends on how  
different the admin funcionality is.

But is there any opinions/experiences you could share on this issue?

Thanks.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 12:07am UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/2 "2008-10-07T00:07:13Z")

</div>

On Oct 6, 2008, at 1:31 PM, comopasta Gr wrote:

> [http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails](http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails)  
> the routing that’s built into rails."
> 
> I’ve used namespaces for admin before and actually it can create  
> confusion. On the other hand using a common controller with some extra  
> is\_admin? checks can be a bit ugly. I know it all depends on how  
> different the admin funcionality is.
> 
> But is there any opinions/experiences you could share on this issue?

I’ve done it quite a few times… rails 1.1.6, 1.2.3, and several with  
whatever is current 2.1.1 (?). I haven’t had any problems…

-philip

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 1:57am UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/3 "2008-10-07T01:57:55Z")

</div>

On Mon, Oct 6, 2008 at 9:31 PM, comopasta Gr  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m currently having the admin part of one of my apps accessible by pure  
> username and password + role management checking.
> 
> I was planning to add namespaces for it. Then I came accross this (a bit  
> old but still…):  
> [http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails](http://glu.ttono.us/articles/2006/08/30/guide-things-you-shouldnt-be-doing-in-rails)

## That article is very old. I’d recommend namespacing controllers for something like admin panel. It has worked great for me.

Cheers!

- Pratik  
[http://m.onkey.org](http://m.onkey.org)

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 3:06am UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/4 "2008-10-07T03:06:24Z")

</div>

On 7 Oct 2008, at 01:49, Robby R. wrote:

> > > (a bit  
> > > The only issue that we’ve really run into is with namespaces and model  
> > > names. Some weird stuff can happen (especially within tests) if you  
> > > have a namespace of Admin and a model named Admin. We’ve since used  
> > > Administrator to as an appropriate model name to distinguish the two.

Might that be weird stuff like it trying to resolve a constant like  
Admin::SettingsController by looking inside the Admin model class ?

I’ve got apps with /admin namespaced controllers on several apps.

Fred

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 2:51am UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/5 "2008-10-07T02:51:11Z")

</div>

On Mon, Oct 6, 2008 at 4:57 PM, Pratik [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> That article is very old. I’d recommend namespacing controllers for  
> something like admin panel. It has worked great for me.

Agreed. We use an /admin namespace on several of our really large  
client projects. It works quite well.

The only issue that we’ve really run into is with namespaces and model  
names. Some weird stuff can happen (especially within tests) if you  
have a namespace of Admin and a model named Admin. We’ve since used  
Administrator to as an appropriate model name to distinguish the two.

Good luck!

Cheers,  
Robby

–  
Robby R.  
Chief Evangelist, Partner

PLANET ARGON, LLC  
design // development // hosting

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[http://www.robbyonrails.com/](http://www.robbyonrails.com/)  
aim: planetargon

+1 503 445 2457  
+1 877 55 ARGON [toll free]  
+1 815 642 4068 [fax]

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 11:54pm UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/6 "2008-10-07T23:54:20Z")

</div>

Hi,

Thanks for your comments. I decided to go for the admin namespace, I  
need to have several controllers under it.

Already posted the first problem. The very first command actually 😛  
Didn’t even have time to get confused 🙂

[http://www.ruby-forum.com/topic/167667](http://www.ruby-forum.com/topic/167667)

Cheers!

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 7, 2008, 6:24pm UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/7 "2008-10-07T18:24:32Z")

</div>

I’ve never had any problems with using an admin namespace either. I  
recommend doing it.

– Josh  
[http://iammrjoshua.com](http://iammrjoshua.com)

Frederick C. wrote:

> On 7 Oct 2008, at 01:49, Robby R. wrote:
> 
> > > > (a bit  
> > > > The only issue that we’ve really run into is with namespaces and model  
> > > > names. Some weird stuff can happen (especially within tests) if you  
> > > > have a namespace of Admin and a model named Admin. We’ve since used  
> > > > Administrator to as an appropriate model name to distinguish the two.
> 
> Might that be weird stuff like it trying to resolve a constant like  
> Admin::SettingsController by looking inside the Admin model class ?
> 
> I’ve got apps with /admin namespaced controllers on several apps.
> 
> Fred

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [October 8, 2008, 4:08am UTC](https://www.ruby-forum.com/t/namespaces-for-admin-fucntionality-worth-the-effort/150282/8 "2008-10-08T04:08:47Z")

</div>

Yes, I tend to break each major part of my app, into a namespace.  
If its a “top” tab on my menu, its a namespace.  
It make life so much easier. So yes, admin is almost always  
in every app. Espesially when you start having dozens to hundreds of  
controllers. Havent quite got to having a “model” in different  
namespace yet  
but got close.

On Oct 8, 5:54 am, comopasta Gr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
