On Jul 30, 2007, at 9:02 PM, Dusty Doris wrote:

> I have a question about changeset 355  for "Initial support for
> controllers to be nested in modules and directories."
>
> I have probably overlooked something here, but it appears to me that
> something is missing to be able to route to those nested controllers.
>
> Looking in Merb::Dispatcher, it looks like the workflow goes like  
> this.
>
> route = route_path(request_uri)
>   route_path then calls Merb::Router.match(path)
>
> klass = resolve_controller(route[:controller])
>   resolve_controller then splits the controller part of the route with
>   segments = controller_name.split('/').map{|s| s.snake_case}
>
> However, it appears that Merb::Router.match isn't handing back  
> "module/class".
>
> For example:
>
> If I setup say an Admin::Articles controller, with an articles
> resource, then these are the results of those methods.
>
> route = Merb::Dispatcher.route_path("/admin/articles")
> => {:controller=>"articles", :rest=>true, :allowed=>{:get=>"index",
> :post=>"create"}}
>
> Which then resolve_controller gives me:
>
> Merb::Dispatcher.resolve_controller(route[:controller])
> => Articles
>
> However, if I pass it manually like this, it works.
>
> Merb::Dispatcher.resolve_controller("admin/articles")
> => Admin::Articles
>
> Is this a missing piece in Router.match or am I supposed to be setting
> up some other type of route in router.rb in order for this to all
> work?
>
> Sorry if its obvious, its not jumping out at me right now.
>
> Thanks
> Dusty Doris


Dusty-

        I need to write up some docs for this somewhere but the way this  
works right now is that when you define the route in router.rb you  
have to set the :controller => 'admin/articles'

so

r.resources :articles, :controller => 'admin/articles'

        I probably need to update the routing syntax with a namespace option  
since you trying to use a top level articles and an admin/articles  
using r.resources :articles will step on each other.

        Thats why I said it was preliminary support ;)


Cheers-
-- Ezra Zygmuntowicz 
-- Founder & Ruby Hacker
-- [EMAIL PROTECTED]
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)


_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to