[英]Rails 3 routing help, how can I use resources for this?
My account_controller has the following actions: 我的account_controller有以下操作:
/accounts/index /accounts/show/12321 /accounts/edit/234234 / accounts / index / accounts / show / 12321 / accounts / edit / 234234
I have this so far in my routes file: 到目前为止,我的路线文件中包含以下内容:
get "accounts/index"
match "accounts/show/:id" => "accounts#show"
Can I use resources instead somehow? 我可以以某种方式使用资源吗?
Currently my accounts#index
routes doesn't work if you have a url like: 目前,如果您有以下网址,则我的
accounts#index
路由不起作用:
/accounts/
Using resources
would change your URL structure: 使用
resources
会改变您的URL结构:
But the action names in the controller would stay the same. 但是控制器中的动作名称将保持不变。
If you don't mind losing the old URLs, or if you could set up redirects from the old URLs to the new ones, then using resources
would result in a more conventional, RESTful design, so it's "better" by that standard. 如果您不介意丢失旧URL,或者可以设置从旧URL到新URL的重定向,那么使用
resources
将导致更传统的RESTful设计,因此按该标准“更好”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.