1
2

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 5 years have passed since last update.

gretelで個別にviewにパンくずを表示する

1
Last updated at Posted at 2017-04-24

経緯

gretelを使用してviewのpartialにパンくずを表示させたかったので。

書き方

partialに以下のように書く。application.html.erbに <%= breadcrumbs separator... は書かない。

<% breadcrumb :category, @category %>
<%= breadcrumbs separator: ' &rsaquo;&rsaquo; ', link_current: true %>

一般的な書き方

よくある使いかたとしては以下のようにapplication.html.erb記述することで全ページから参照することが出来る。

app/views/layouts/application.html.erb
<html>
<head>
  <title>MyApp</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>
  <div class="container">
    <p><%= breadcrumbs separator: " &rsaquo; " %></p> 
      <%= yield %>
  </div>
</body>
</html>
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?