Ruby on Rails 路由 - get 和 match 之间的区别 [英] Ruby on Rails Routes - difference between get and match

查看:29
本文介绍了Ruby on Rails 路由 - get 和 match 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会有什么不同?

示例匹配:
匹配照片/节目"=>'照片#show'

示例获取:
获取'照片/节目'

是否既可以访问照片/节目网址,又可以使用照片控制器中的 show 操作?

Wouldn't both make it possible to reach the photos/show URL and also use the show action in the photos controller?

谢谢

推荐答案

match 匹配任何 http 方法/动词,而 get 只匹配 http 方法/动词 GET.

match matches any http method/verb, while get matches only http method/verb GET.

以下两个是等价的:

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

这篇关于Ruby on Rails 路由 - get 和 match 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆