简体   繁体   English

如何在Rails 2.3和3中路由:collection以使用/ controller / action /:id?

[英]How do I route :collection to use /controller/action/:id in rails 2.3 & 3?

If I have code that looks like this: 如果我有这样的代码:

:collection => {
  :download_print_use => :get
}

rake routes dosn't show me how to use :id to map to something like /controller/download_print_use/:id 耙路线并没有告诉我如何使用:id映射到类似/ controller / download_print_use /:id的对象

what do I need to do to make this work? 我需要做些什么才能使这项工作?

Because that's the point of the collection option. 因为那是收集选项的重点。 Ex: events/download_print . 例如: events/download_print

I think you need to use :member => {} to get what you want. 我认为您需要使用:member => {}来获得所需的内容。


It's the same principle in rails 3, but with a more elegant syntax. 它与Rails 3中的原理相同,但是语法更优雅。 You can read this paragraph to understand it better: http://guides.rubyonrails.org/routing.html#adding-more-restful-actions 您可以阅读此段落以更好地理解它: http : //guides.rubyonrails.org/routing.html#adding-more-restful-actions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将特定的控制器动作路由到Rails中的特定表单? - How do i route a particular controller action to a particular form in rails? 如何路由到新的rails控制器操作 - How do I route to a new rails controller action 如何使用页面ID /名称加载正确的控制器操作? (Ruby on Rails 4) - How do I use a page id/name to load the correct controller action? (Ruby on Rails 4) 如何在Rails 2.3路由中指定默认值? - How do I specify a default in a rails 2.3 route? Rails:我如何在控制器/动作上使用javascript条件 - Rails: how do I use javascript conditional on controller/action 如何在Rails Controller / Action中使用Ruby改进? - How do I use Ruby refinements inside Rails Controller/Action? Rails路由:如何路由到特定的控制器/动作/ ID? - Rails Routing: How to route to a specific controller/action/id? Rails 4-如何基于当前路径显示同一控制器动作的不同视图? - Rails 4 - How do I show a different view for the same controller action, based on the current route? 如何将操作路由到Rails 3中的应用程序控制器? - How do you route an action to the application controller in Rails 3? 如何将编辑表单路由到控制器中的update操作? (轨道应用) - How do I route an edit form to the update action in my controller? (Rails app)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM