You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I also have a separate partial, where I render the breadcrumbs in a loop to be included in my layout.
Now, I want to cache the output of my this partial so it's not constantly hitting the DB when rendering the breadcrumbs. How to do that using fragment caching?
I'm new to caching in Rails, but my understanding is that I should get whatever it was I had passed to breadcrumb and create a cache_key based off that.
It would be nice if I could call breadcrumb without any arguments, to get whatever was previously set as the current breadcrumb.
So then I could do something like this in my breadcrumb partial:
<% cache(breadcrumb) do %>
<% breadcrumbs.tap do |links| %>
<% if links.any? %>
<div class="breadcrumbs breadcrumbs-fixed" id="layout-breadcrumbs">
<div class="container">
<ul class="breadcrumb">
<% links.each do |link| %>
<li<%= ' class="current"' if link.current? %>>
<% if link.icon.present? %>
<i class="ace-icon<%= " #{link.icon}" %>"></i>
<% end %>
<% if link.current? %>
<%= link.text %>
<% else %>
<%= link_to link.text, link.url %>
<% end %>
</li>
<% end %>
</ul>
</div>
</div>
<% end %>
<% end %>
<% end %>
Reading the doco though, it doesn't look like that is possible.
Is there any easy way to get the current breadcrumb (or really whatever object/symbol passed to breadcrumb), without looping through the actual breadcrumbs (and triggering a DB lookup)?
In my views, I'm calling
breadcrumb
like so:or sometimes
I also have a separate partial, where I render the breadcrumbs in a loop to be included in my layout.
Now, I want to cache the output of my this partial so it's not constantly hitting the DB when rendering the breadcrumbs. How to do that using fragment caching?
I'm new to caching in Rails, but my understanding is that I should get whatever it was I had passed to
breadcrumb
and create acache_key
based off that.It would be nice if I could call
breadcrumb
without any arguments, to get whatever was previously set as the current breadcrumb.So then I could do something like this in my breadcrumb partial:
Reading the doco though, it doesn't look like that is possible.
Is there any easy way to get the current breadcrumb (or really whatever object/symbol passed to
breadcrumb
), without looping through the actual breadcrumbs (and triggering a DB lookup)?Original issue: #40
The text was updated successfully, but these errors were encountered: