0
0

More than 3 years have passed since last update.

一部のviewでしか、表示させたくないものがあるときの対処法 if

Last updated at Posted at 2019-12-16

URLごとに表示を変えたいとき

request.path.include?()を使うと良い。()の中の文字がURLに入っているかいないかを判断する。


<%if request.path.include?("mypage")%>
 <li class="nav-item active">
  <%= link_to '「ものを作る」', new_mypage_product_path, class:"nav-link"%>
 </li>
<%end%>

参考 https://qiita.com/Yohei_Shiina/items/ed39dfd74895d54f3cf2

0
0
1

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