match 'photos/:id'=>'photos#show'match 'photos/:id', to: 'photos#show'match 'photos/:id', controller: 'photos', action: 'show'
模式匹配,也可以直接指向 Rack application. 因为它实现了 call 方法:
match 'photos/:id', to: lambda {|hash| [200, {}, ["Coming soon"]] }match 'photos/:id', to: PhotoRackApp# YourController.action(:your_action) 也是 rack endpointmatch 'photos/:id', to: PhotosController.action(:show)
通过 HTTP 请求,容易带来安全隐患,所以你可以使用 HtttpHelpers[rdoc-ref:HttpHelpers],而不是 match
另:
match
|
V
decomposed_match (还分几种情况)
|
V
add_route
|
V
@set.add_route
其它:
其它方法:
nested 和 root
|
V
scope
namespace
|
V
super (即 Scoping 里的 namespace)
|
V
scope