如何将一些复杂的路线从 Rails 2.3 转换为 Rails 3.1?

发布于 2024-12-29 01:24:09 字数 660 浏览 0 评论 0原文

我正在开发一个项目,将 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 网站上的路线文档,但我仍然无法获取它。

I am working on a project where I am upgrading a Rails 2.3 application to Rails 3.1. There is one thing which I am not able to figure out. Below is a route defined in a Rails 2.3 application:

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

I am not sure how to write this route using Rails 3.1 to perform the same functionality which this route is performing using Rails 2.3. I searched online to find some resources which explains this and also I read the routes documentation on the Ruby on Rails website but I still can't get it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多像笑话 2025-01-05 01:24:09

这里免费编码,但我想这会为你做的

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

free coding here but I guess this would do it for you

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文