LoginSignup
0
0

More than 5 years have passed since last update.

link_toにパラメータを渡す

Posted at

link_toで検索条件などGETでパラメータを渡す場合です。

html.erb

<%= link_to "AAA", issues_path(searcher: { product_id: product.id }), class: 'nav-link' %>

issues_path GET /issues(.:format)

htmlでの表示

<a class="nav-link" href="/issues?searcher%5Bproduct_id%5D=1">AAA</a>

paramsの中身

{"searcher"=>{"product_id"=>"1"}

controllerでのアクセス

params[:searcher][:product_id]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0