Hello, I''ve got some problems migrating from rails2 to rails3: I have some controllers in a subdirectory, and I want to access them in a non-restful/resourceful way. Previously I just created a controller in /util, prefixed the class name with Util:: and it worked, that is /util/controller_name/action_name was routed properly. I was trying various approaches with :namespace, e.g.: namespace :util do match '':controller(/:action(/:id(.:format)))'' end but that throws an exception during boot: ":controller segment is not allowed within a namespace block" What is the proper way to map such controllers? -- Thanks, Adam Warski -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2010-Nov-29 13:22 UTC
Re: Rails2 to rails3 routes migration problem - namespaces
On Nov 29, 5:08 am, "Adam W." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> What is the proper way to map such controllers?The Routing guide seems to cover this topic pretty well: http://edgeguides.rubyonrails.org/routing.html#dynamic-segments -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ah, I was looking for a proper :namespace usage. This indeed helps, though now I have: match '':controller(/:action(/:id))'', :controller => /tabs\/[^\/]+/ match '':controller(/:action(/:id))'', :controller => /util\/[^\/]+/ match '':controller(/:action(/:id(.:format)))'' which may not seem obvious at first. But you just need a way to tell Rails to look beyond the first / when finding the controller name. Thanks, Adam -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.