gpt4 book ai didi

ruby-on-rails-4 - 使用 splat 匹配路线。它有什么作用?

转载 作者:行者123 更新时间:2023-12-03 09:15:04 24 4
gpt4 key购买 nike

我看到这条路线:

将“*a”匹配到:“application#some_error_handler”,通过::all

这在 Rails 中起什么作用?这是一个“a”吗?

最佳答案

这称为路由通配,并在 Routing guide's section on route globbing 中进行了解释。 :

Route globbing is a way to specify that a particular parameter should be matched to all the remaining parts of a route. For example:

get 'photos/*other', to: 'photos#unknown'

This route would match photos/12 or /photos/long/path/to/12, setting params[:other] to "12" or "long/path/to/12". The fragments prefixed with a star are called "wildcard segments".

Wildcard segments can occur anywhere in a route. For example:

get 'books/*section/:title', to: 'books#show'

关于ruby-on-rails-4 - 使用 splat 匹配路线。它有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38641799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com