Ruby on Rails路线-获取与匹配之间的区别


73

有什么区别?

匹配示例:
match 'photos/show' => 'photos#show'

示例获取:
get 'photos/show'

既可以访问照片/显示URL,又可以在照片控制器中使用show操作吗?

谢谢

Answers:


132

match匹配任何http方法/动词,而get仅匹配http方法/动词GET。

以下两个是等效的:

match "/signup" => "users#new", :via => [:get]
get   "/signup" => "users#new"

如果via未指定匹配的内容呢?
userMod2

1
@ userMod2它将匹配任何http方法,即post,put,get,delete;所有这些
充满活力
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.