2011-01-06 81 views
0

如何将这种路线是在梁2至3轨路由在Rails3中

%w(a).each do |attr| 
    map.resources :b, :name_prefix => "#{attr}_", :path_prefix => "/#{attr.pluralize}/:#{attr}_id" 
    end 

    map.resources :a do |s| 
    s.resources :t do |ts| 
     ts.resources :p 
     ts.resource :m, :controller => :m 
    end 
    end 
end 

在这个任何想法转换?

回答

0

你试过吗?

%w(a).each do |attr| 
    resources :b, :name_prefix => "#{attr}_", :path_prefix => "/#{attr.pluralize}/:#{attr}_id" 
end 

resources :a do 
    resources :t do 
    resources :p 
    resources :m, :controller => :m 
    end 
end 

编辑:按照注释

map.resources :q, :name_prefix => 'all_', :collection => { :search => :get } 

可以写成

resources :q, :name_prefix => 'all_' do 
    collection do 
    get :search 
    end 
end 

东西与缩进和额外的结束粘贴的代码似乎掉?

+0

谢谢你的快速反应如何在轨道3例如使用此航线部分:map.resources:Q,:name_prefix => 'ALL_',:收集=> {:搜索=>:得到} – sam 2011-01-06 08:50:20