Rails 不能直接在 route 处理带 ? 的 url 么?

hick · August 16, 2013 · 2004 hits

搜了下,官方 route 的文档也大概扫了下,貌似没涉及这方面的?

比如我是想把 /?p=1 这样的请求重定向成 /posts/show/1 这样的。下面这样的定义不奏效。 ? 前加反斜杠也没用,现在只得在 action 中处理 params[:p] 了?

get '/?p=:id', to: 'posts#show', constraints: { id: /[0-9]+/ }

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.