Created
July 7, 2011 23:02
-
-
Save visoft/1070758 to your computer and use it in GitHub Desktop.
Custom Breadcrumb Builder that handles a render action from the controller using breadcrumbs_on_rails. Instead of highlighting the "middle" item as active, e.g. Home >> **Widgets** >> New, the last item will be highlighted instead (so New in the previous
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage | |
= render_breadcrumbs :builder => BreadcrumbBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The controller code | |
def new | |
add_breadcrumb 'New', new_widget_path | |
end | |
def create | |
@widget = Widget.new(params[:widget]) | |
if @widget.save | |
redirect_to @widget, notice: 'Widget was successfully created.' | |
else | |
add_breadcrumb 'New', new_widget_path | |
render 'new' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment