所以我有这个查询字符串
<a href="/reports/user?q=<%= current_user.id %>">
# => /reports/user?q=1
在rails 3中运行良好,但抛出
Couldn't find Report with id=user
使用rails 4。
#routes.rb
get "reports/:field" => "reports#search"
答案 0 :(得分:1)
你在这里路线
get "reports/:field" => "reports#search"
将使用search
params = {field:"user"}
方法
如果您希望它使用相同的网址,请将路由更改为:
get "reports/user" => "reports#search"
并在search
中使用q
代替field
或强>
将链接更改为
<a href="/reports/<%= current_user.id %>">