1

我正在開發一個項目,將Rails 2.3應用程序升級到Rails 3.1。有一件事我無法弄清楚。下面是在Rails 2.3的應用程序定義的路由:如何將一些複雜的路線從Rails 2.3翻譯成Rails 3.1?

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

這裏免費的編碼,但我想這會爲你做

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 
+0

@ yper:感謝您的幫助。在我看來你是對的。 – user814446

+0

很高興幫助:) –