2012-10-23 126 views
1

。如何去從Rails 2.3.5嵌套路由在Rails 2.3.5中替換/刪除路由

rake routes 
(in /home/railsApp) 
tv_shows  GET /tv_shows(.:format) {:controller=>"tv_shows", :action=>"index"} 
      POST /tv_shows(.:format) {:controller=>"tv_shows", :action=>"create"} 
new_tv_show GET /tv_shows/new(.:format) {:controller=>"tv_shows", :action=>"new"} 
edit_tv_show GET /tv_shows/:id/edit(.:format) {:controller=>"tv_shows", :action=>"edit"} 
tv_show GET /tv_shows/:id(.:format)  {:controller=>"tv_shows", :action=>"show"} 
PUT /tv_shows/:id(.:format)    {:controller=>"tv_shows", :action=>"update"} 
DELETE /tv_shows/:id(.:format)    {:controller=>"tv_shows", :action=>"destroy"} 

rake routes 
(in /home/railsApp) 
tv_shows  GET /tv/shows(.:format) {:controller=>"tv/shows", :action=>"index"} 
      POST /tv/shows(.:format) {:controller=>"tv/shows", :action=>"create"} 
new_tv_show GET /tv/shows/new(.:format) {:controller=>"tv/shows", :action=>"new"} 
edit_tv_show GET /tv/shows/:id/edit(.:format) {:controller=>"tv/shows", :action=>"edit"} 
tv_show GET /tv/shows/:id(.:format)  {:controller=>"tv/shows", :action=>"show"} 
PUT /tv/shows/:id(.:format)    {:controller=>"tv/shows", :action=>"update"} 
DELETE /tv/shows/:id(.:format)    {:controller=>"tv/shows", :action=>"destroy"} 

route.rb

map.namespace :tv do |tv| 
['shows', 'summaries'].each do |controller| 
    tv.connect "#{controller}/:action", 
    :controller => controller, 
    :conditions => { :method => :get }, 
    :requirements => { :action => /auto_complete_for_\S+/ } 
end 

tv.resources :summaries 
tv.resources :shows 

在DB的表名爲tv_shows。但在我的應用程序中,我有文件夾電視文件顯示在其中。

App = ruby 1.8.6 and Rails 2.3.5 

你能指點我一個好的嵌套路線,命名空間教程。

+0

試試這個['shows','summaries']。each do | controller | tv.connect「tv /#{controller} /:action」, :controller =>「tv /#{controller}」, :conditions => {:method =>:get}, :requirements => { :action =>/auto_complete_for_ \ S + /} – Raghu

+0

如果它工作,然後生病添加它作爲答案 – Raghu

+0

不,它沒有工作。 – mamesaye

回答

0

map.resources :tv_summaries 
map.resources :tv_shows 

所有的一切都取決於頂在我的route.rb文件註釋這兩個線固定的問題。