Hi all
I have the following website structure:
In the namespace "music" I have artists, styles and labels, where
artists also acts as namespace containing types:
map.namespace :music do |music|
music.resources :artists
music.namespace :artists do |artists|
artists.resources :types
end
music.resources :styles
music.resources :labels
end
So I''d expect the following URL structure:
music/artists
music/artists/types
music/styles
music/labels
Everything works great, except when opening music/artists/types I get
the exception
NoMethodError in Music/artists/types#show
Showing music/artists/types/show.html.erb where line #2 raised:
undefined method `edit_music_artists_types_path'' for
#<ActionView::Base:0x24207a0>
Extracted source (around line #2):
1:
2: <%= link_to ''Edit'',
edit_music_artists_types_path(@music_artist_types) %> |
3: <%= link_to ''Back'', music_artists_types_path %>
Anyone sees the problem...? Isn''t it possible to use :artists als
namespace?
Thanks a lot,
Josh
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
the edit action requires a singular methof edit_music_artists_type_path(id) you''re using the plural. most likely that''s it. otherwise it''s more likely, that types or type is a ruby keyword than artists. oops, just realize, you''re using a namespace, that''s the same name as a controller, that most likely won''t work... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Fri, Mar 21, 2008 at 12:28 AM, Joshua Muheim <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > map.namespace :music do |music| > music.resources :artists > music.namespace :artists do |artists| > artists.resources :types > end > music.resources :styles > music.resources :labels > end >http://api.rubyonrails.org/classes/ActionController/Routing/RouteSet/Mapper.html Sniffer from the docs: {{{ namespace(name, options = {}, &block) Enables the use of resources in a module by setting the name_prefix, path_prefix, and namespace for the model. Example: map.namespace(:admin) do |admin| admin.resources :products, :has_many => [ :tags, :images, :variants ] end This will create admin_products_url pointing to "admin/products", which will look for an Admin::ProductsController. It''ll also create admin_product_tags_url pointing to "admin/products/#{product_id}/tags", which will look for Admin::TagsController. }}} -- Regards, Josh.Yin/殷海明/A.K.A epaulin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller wrote:> the edit action requires a singular methof > > edit_music_artists_type_path(id) > > you''re using the plural. > most likely that''s it. otherwise it''s more likely, that types or type is > a ruby keyword than artists. > > oops, just realize, you''re using a namespace, that''s the same name as a > controller, that most likely won''t work...Surprisingly this really was the problem. I changed it to the singular form, and now it works perfectly. So it seems not to be any problem to nest namespaces and resources. :-) Thanks you guys! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---