我正在开发一个项目,我将Rails 2.3应用程序升级到Rails 3.1。有一件事我无法弄明白。下面是Rails 2.3应用程序中定义的路由:
map.resources :segments, :collection => { :listen => :get, :comment => :post, :inside => :post, :around => :post , :suggest => :get, :ipeds => :get, :search_ipeds => :get }, :member => { :listen => :get }, :has_many => [ :photos , :school_statistics, :comments, :ad_spots ] do |segments|
segments.resources :visits , :only => [ :index ], :collection => { :destroy_all => :delete }
end
我不确定如何使用Rails 3.1编写此路由来执行此路由使用Rails 2.3执行的相同功能。我在网上搜索了一些解释这个的资源,并且我在Ruby on Rails网站上阅读了路线文档,但我仍然无法得到它。
答案 0 :(得分:0)
这里是免费编码,但我想这会为你做到
resources :segments do
collection do
get 'listen'
post 'comment'
post 'inside'
post 'around'
get 'suggest'
get 'ipeds'
get 'search_ipeds'
end
member do
get 'listen'
end
resources :photos
resources :school_statistics
resources :comments
resources :ad_spots
resources :visits , :only => [ :index ] do
delete 'destroy_all', :on => :collection
end
end