This project is archived and is in readonly mode.
Not routing to correct non-default controller
-
Andrew White
- State changed from new to needs-more-info
- Importance changed from to Low
Need a bit more of your routes.rb file to see what's happening - to get the '/articles/:id' part of the path the resources call needs to be wrapped with something, e.g:
resources :articles do member do resources :front_page_articles, :only => [:new, :create], :controller => 'articles/front_page_articles' end endFirstly the 'member' should be 'nested' - member is for specifying actions on the current resource not defining nested resources. If you'd used nested the path would be '/articles/:article_id', however this is irrelevant because it still works anyway. Using the above routes in a test application (Rails 3.0.5) this is what I get:
$ curl http://127.0.0.1:3000/articles/1/front_page_articles/new {"action"=>"new", "id"=>"1", "controller"=>"articles/front_page_articles"}The only way I can reproduce your problem is if a controller exists at app/controllers/front_page_articles_controller.rb and not at app/controllers/articles/front_page_articles_controller.rb. Because of how AS::Dependencies works it will find a constant in the global namespace if one in the Articles namespace doesn't exist or the Articles namespace doesn't exist. Check you haven't got a typo in a path somewhere - that's probably the cause of the problem.
-
mikemaltese
Hi Andrew,
I've already moved past this issue by renaming some controllers, so my routes.rb file would be of no help. From what I remember, however, I did have controllers with the same name defined in the root scope and in the 'articles' scope, and it was routing to the root one when it shouldn't have.