【发布时间】:2016-05-02 13:41:09
【问题描述】:
我的报告页面中的 url 通常如下所示:
http://test-account.peter:3000/offices/7/reports/index
但是,有时它看起来像这样:
http://test-account.peter:3000/offices/7-peters-office/reports/index
为什么会这样?
在我们将控制器操作从 GET 更改为 POST 并重命名之前,这并不是真正的问题。我们必须这样做,以便我们可以将更多参数打包到 ajax 请求中。用户仍然将网站的这一部分添加为书签,并且整天都会抛出错误。
我已尝试重定向路线:
get '/offices/*all/reports/index' => 'offices#show'
get '/offices/:office_id/reports/index' => 'offices#show'
get '/offices/:office_name/reports/index' => 'offices#show'
有没有办法抓住名字?还是我必须首先阻止将名称添加到 URL 中?
【问题讨论】:
标签: ruby-on-rails ruby routes