I have an application with a frontend and admin backend. In both
sections there are controllers with the same name (e.g.
CampaignsController and Admin::CampaignsController). The front and
backend controllers have seperate authentification methods (for users
and admins). When a admin browses to admin -> campaigns they are
redirected to the frontend login screen as if they had browsed to the
frontend campaigns controller. The problem is solved when product.rb -
> config.cache_classes is set to false OR when all the admin
controller names are prefixed with 'Admin' (e.g.
Admin::AdminCampaign). Is there any other way I can get around this?
has anyone else experienced this problem?
Many Thanks,
Peter
--
Cheers!
- Pratik
http://m.onkey.org
Indeed you should. Namespacing of controllers has been a pain in Rails
<= 1.2 but Rails 2.0 does offer support for namespaced controllers. In
config/routes.rb:
map.namespace(:admin) do |admin|
admin.resources :campaigns
...
end
--
Roderick van Domburg
http://www.nedforce.com
--
Posted via http://www.ruby-forum.com/.
I thought before I tried edge rails that I would replicate the problem
locally. So I've run the app using the production env and using
mongrel instead of webrick, all the versions are the same yet the
problem doesn't appear. Any ideas?
Peter
On Sep 21, 12:00 pm, Roderick van Domburg <rails-mailing-l...@andreas-
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/inflector.rb:250: warning: toplevel constant
CampaignsController referenced by Admin::CampaignsController
Any ideas?
Peter
Oh, I bet you're right. I"m getting bit by the same issue right now. I
have two types of namespaced controller: admin and school. The admin
namespace has no issues, but the school namespaced controllers
completely blow up _only_ when running "rake test:functionals", not when
running their tests by themselves.
I'm also getting this problem with Rails 2.0.2. I've noticed that I can
make the problem go away by turning off cache_classes in the
configuration.
config.cache_classes = false
With it on My controllers Admin::PageController & PageController often
get muddled causing all my tests to explode :(
I guess that leans further towards this being an issue of caching and
not respecting namespaces...
--
Joseph Wilk
http://www.joesniff.co.uk
http://peat.wordpress.com/2006/06/30/watch-your-namespace/
Do you also have a model with the same name as your namespace? I did.
Seems like this should have been fixed by rails 2.0.2, but it looks like
it's happening again