路径

时间:2017-09-28 08:25:45

标签: ruby-on-rails routes

看来每当get scope内有约束时,scope的约束都会被忽略:

此处识别路线:

scope '(/:optional_slug)', constraints: ->(req) { raise 'first constraint!' } do
  get '/:category/:slug(/:locale)' => 'public/posts#show', 
    constraints: ->(req) { true }
end

此处second constraints被提出:

scope '(/:optional_slug)', constraints: ->(req) { raise 'first constraint!' } do
  get '/:category/:slug(/:locale)' => 'public/posts#show', 
    constraints: ->(req) { raise 'second constraint!' }
end

仅当我从first constraint!

中删除约束时才会引发get
scope '(/:optional_slug)', constraints: ->(req) { raise 'first constraint!' } do
  get '/:category/:slug(/:locale)' => 'public/posts#show'
end

我无法在解释此类行为的文档中找到它。我错过了什么或者它是一个错误吗?

0 个答案:

没有答案