0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Rails】Bootstrapのnavbarで綺麗にログアウトリンクを表示する方法

Posted at

概要

  • deviseを導入
  • Bootstrapで”Navbar fixed”を導入し、ヘッダーで「マイページ」や「ログアウト」リンクを設置しようというところ

困ったこと

  • 以下HTMLだとリンクがヘッダー内で微妙に下にずれ、なぜか綺麗に表示されない。また、CSSもなぜか反映されない。
_header.html.erb
<li class="nav-item">
 <a class="nav-link"><%= link_to 'ログアウト', destroy_user_session_path, :method => :delete %></a>
</li>

解決方法

  • aタグではなく、Railsで一般的に使われるlink_toで以下のようにclass指定したら綺麗に反映されました。
_header.html.erb
<li class="nav-item">
 <%= link_to "ログアウト", destroy_user_session_path, method: :delete, class: 'nav-link' %>
</li>
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?