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?
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…
(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.
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
(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.
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.