23 Jul 06:39
named routes in admin namespace
From: giorgio <george.peverell@...>
Subject: named routes in admin namespace
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-23 04:43:01 GMT
Subject: named routes in admin namespace
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2008-07-23 04:43:01 GMT
Hi,
I have a controller Admin::Categories in folder controllers/admin
I have a views/admin/categories/index.html.erb which contains:
<%= link_to 'New category', new_category_path %>
now if my routes.rb contains:
map.resources :categories
Then the generated url does not have /admin/ on the front ie it is:
/categories/new which does not work as the controller is in /admin
If I do something that seems to be suggested in the comments in
routes.rb ie:
map.namespace :admin do |admin|
admin.resources :categories
end
I get:
undefined local variable or method `new_category_path' for
#<ActionView::Base:0xb6fb5854>
How do I get these fancy named routes to work in the admin namepace?
I could have bunged in :controller=>'categories' , :action=>'new'
However we are told that these named routes are smarter....?
Any help appreciated
George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
RSS Feed