Skip to content

Instantly share code, notes, and snippets.

@natew
Created October 16, 2012 06:26
Show Gist options
  • Save natew/3897524 to your computer and use it in GitHub Desktop.
Save natew/3897524 to your computer and use it in GitHub Desktop.
Simple automatic breadcrumbs in rails 3
#breadcrumbs {
a {
float: left;
&:hover {
color: #fff;
&.after:after {
color: #aaa;
}
}
&.highlight {
color: #ccc;
font-weight: bold;
&:after {color: #aaa;}
}
&.after:after {
display: inline-block;
padding: 0 5px;
margin: -2px 0 0;
font-size: 10px;
content: ">";
}
}
}
<%- second_level = action_name =~ /index/i || @primary.nil?
separate = second_level ? '' : 'after'
if !second_level
-%>
<div id="breadcrumbs">
<%= link_to 'Home', '/', :class => 'after' %>
<%= link_to controller_name.capitalize, '/' + controller_name, :class => separate if second_level %>
<%- if !second_level -%>
<%= link_to @primary.class.name.pluralize, '/' + @primary.class.name.downcase.pluralize, :class => separate + ' highlight' %>
<%= link_to @primary.get_title, @primary %>
<%- end -%>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment