gretel+bootstra4でパンくず
やりたいこと
bootstrap4 の breadcrumb でパンくずをつくる。
課題
<% breadcrumb :issue, @issue %>
ヘルパーのオプションでは li
タグにclassを指定ができない。
解決方法
manually で対応する
手順
Gemfile
gem 'gretel'
インストール
$ bundle install --path=vendor/bundle $ ./bin/rails g gretel:install create config/breadcrumbs.rb
パンくずを設定
$ vim config/breadcrumbs.rb
view
... <% breadcrumbs.tap do |links| %> <% if links.any? %> <div class='container'> <ol class='breadcrumb'> <% links.each do |link| %> <li class='breadcrumb-item<%= ' active' if link.current? %>'> <%= link_to_unless(link.current?, link.text, link.url) %> </li> <% end %> </ol> </div> <% end %> <% end %> ...
メモ
<% breadcrumbs do |links| %>
と実装すると、[Gretel] Calling
breadcrumbswith a block has been deprecated and will be removed in Gretel version 4.0. Please use
tapinstead. Example:
とログが出力されたので、tap
で対応。
完成