14

rails routes中resource和resources的区别

 3 years ago
source link: http://blog.ilibrary.me/2020/09/13/rails-routes%E4%B8%ADresource%E5%92%8Cresources%E7%9A%84%E5%8C%BA%E5%88%AB
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
rails routes中resource和resources的区别
欢迎转载,请支持原创,保留原文链接:blog.ilibrary.me

rails routes中resource和resources区别是什么?

区别是, resource生成的路径永远不带id, 也没有index路径. 即使嵌套memmber do,路径里面也不会有/:id/这部分值。

resources生成的路径带id, 还会默认生成 index. resources :classes do下面的路径默认会添加/:class_id/. 可以在resources下面嵌套resources, 这样就可以在rails routes里面清楚得看到嵌套的id代办的是啥. /:resource1_id/resource2/:resource2_id/

resources下面member do下面的路径默认添加/:id/做为路径的一部分。

扫描二维码分享到微信朋友圈Loading...Please waitqrcode.php?url=%2F2020%2F09%2F13%2Frails-routes%25E4%25B8%25ADresource%25E5%2592%258Cresources%25E7%259A%2584%25E5%258C%25BA%25E5%2588%25AB

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK