Hi All!
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
Did you try this in edge rails ?
On 9/21/07, [email protected] [email protected] wrote:
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!
Thanks for the quick replies.
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-
Pratik Naik wrote:
Did you try this in edge rails ?
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
I’m also seeing this in my mongrel logs on the server:
/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
Peter & all,
Was a solution ever found for this? I’m running on Edge Rails (2.0 RC
- 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
Any thoughts would be appreciated!
Pastie your code
On 9/21/07, [email protected] [email protected] wrote:
On Sep 21, 12:00 pm, Roderick van Domburg <rails-mailing-l…@andreas-
admin.resources :campaigns
–
Cheers!
Jack,
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?
On Nov 25, 5:14 pm, “[email protected]” [email protected]
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…
jack
Continuing my own thought, a quick look at the controller_path() class
method in Rails 2.0 RC1 reveals this:
in action_pack/lib/action_controller/base.rb:
class <<self
def controller_path
@controller_path ||= name.gsub(/Controller$/, ‘’).underscore
end
end
I wonder if there’s a caching issue where that @controller_path ||= is
concerned?
Jared wrote:
Continuing my own thought, a quick look at the controller_path() class
method in Rails 2.0 RC1 reveals this:
in action_pack/lib/action_controller/base.rb:
class <<self
def controller_path
@controller_path ||= name.gsub(/Controller$/, ‘’).underscore
end
end
I wonder if there’s a caching issue where that @controller_path ||= is
concerned?
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.
Thijs C. wrote:
Did anybody learn anything new about this issue? I’m still having
issues with Rails 2.0.2 and I’m kind of lost on what the cause is.
On Dec 9 2007, 8:33 pm, James H. <rails-mailing-l…@andreas-
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 W.
http://www.joesniff.co.uk
This link was helpful for me:
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
Did anybody learn anything new about this issue? I’m still having
issues with Rails 2.0.2 and I’m kind of lost on what the cause is.
On Dec 9 2007, 8:33 pm, James H. <rails-mailing-l…@andreas-