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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If u want to get the url like admin/categories/new then change ur link as <%= link_to new_admin_category_path(@admin) %> On Wed, Jul 23, 2008 at 10:13 AM, giorgio <george.peverell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for that. <%= link_to new_admin_category_path%> (without the @admin) works. However I dont want to change all the links in all the view files! You must be able to generate the scaffold and tell it that it is in Admin namespace so that it does it for you? Otherwise I may as well just convert it to :controller,.... :action.... at least that is easy to read and understand. Cheers 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial This has a good tut.. on rails 2.0 and specifically has examples of the namespace problem. I had the same issue and just found it. On Jul 23, 1:13 am, giorgio <george.pever...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for that. > > <%= link_to new_admin_category_path%> (without the @admin) > works. > > However I dont want to change all the links in all the view files! > You must be able to generate the scaffold and tell it that it is in > Admin namespace so that it does it for you? > > Otherwise I may as well just convert it > to :controller,.... :action.... at least that is easy to read and > understand. > > Cheers > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---