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?
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?
Was a solution ever found for this? I'm running on Edge Rails (2.0 RC
1) and I'm encountering the same thing, only in production, and only
intermittently.
When mongrel has been running for "a while" I start to run into this
same problem, where I have EventsController and
Worker::EventsController. The latter doesn't require authorization,
but links to /worker/events start directing to /events, which in turn
leads to a filter chain halt due to a lack of authorization.
Even more oddly, if I access /worker/events/, I'm redirected properly
to Worker::EventsController, but if I leave off the trailing /, I get
bounced out.
I'm seeing the following in my Mongrel Logs:
/var/www/apps/workerlogic/releases/20071116212637/vendor/rails/
activerecord/lib/../../activesupport/lib/active_support/inflector.rb:
257: warning: toplevel constant EventsController referenced by
Worker::EventsController
I've had the same happen to me; you've hit it on the head exactly with
the "a while" type behavior. Its really perplexing, and I can't think
of what might be going on.
The trailing slash thing doesn't work for me either. I guess I can try
the stuff mentioned earlier, but just wanted to at least chime in with
a "yeah happens to me too" and hope we can figure this out...
While it's not an answer, my best workaround was to move away from
controllers that would have namespace conflicts, so my
Worker::EventsController is now Worker::JobsController.
I suspect the problem comes from having the controllers in different
'levels' of namespace... EventsController was at the root, and
Worker::EventsController was in a namespace. The problem seemed to
come from the latter 'losing' it's namespace. Where, if I had them
each in a namespace, I suspect I wouldn't see the problem. So, maybe
there's something in Rails routing or in mongrel that's asking for
controller_name and not getting the module prepended on it?
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