Rails - Dynamic name routes namespace

Posted by Kuro on Stack Overflow See other posts from Stack Overflow or by Kuro
Published on 2011-01-22T23:12:30Z Indexed on 2011/01/31 23:25 UTC
Read the original article Hit count: 165

Hi,

Using Rails 2.3, I'm trying to configure my routes but I uncounter some difficulties. I would like to have something like :

  • http:// mydomain.com/mycontroller/myaction/myid
    • That should respond with controllers in :front namespace
  • http:// mydomain.com/aname/mycontroller/myaction/mydi
    • That should respond with controllers in :custom namespace

I try something like this, but I'm totaly wrong :

map.namespace :front, :path_prefix => "" do |f|
 f.root :controller => :home, :action => :index
 f.resources :home
 ...

end

map.namespace :custom, :path_prefix => "" do |m|    
 m.root :controller => :home, :action => :index
 m.resources :home
 ...

 m.match ':sub_url/site/:controller/:action/:id'
 m.match ':sub_url/site/:controller/:action/:id'
 m.match ':sub_url/site/:controller/:action/:id.:format'
 m.match ':sub_url/site/:controller/:action.:format'
end

I put matching instruction in custom namespace but I'm not sure it's the right place for it. I think I really don't get the way to customize fields in url matching and I don't know how to find documentation about Rails 2.3, most of my research drove me to Rails 3 doc about the topic...

Somebody to help me ?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about dynamic