Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix name collision #54

Open
wants to merge 1 commit into from

3 participants

@justame

the method breadcrumbs is too common, i use Spree(https://github.com/spree/spree) and it overrides the method "breadcrumbs", so this is suggestion to solve this kind of issues.

@weppos
Owner

I think it makes sense. To push it even further, I suggest to use breadcrumbs_on_rails instead of breadcrumbs_collection so that we prevent every possible issue.

Moreover, the main method should be breadcrumbs_on_rails including the instance variable

def breadcrumbs_on_rails
    @breadcrumbs_on_rails ||= []
end

and it should be aliased as breadcrumbs. Do you mind to make the changes?

@weppos
Owner

Please also make sure to provide the corresponding test.

@ngelx

What is the current state of this PR? I could help to implement this as I it need for a projects i'm working on.

@ngelx

I've done the suggested changes on #65. Please take a look and let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 26, 2014
  1. @justame

    fix name collision

    justame authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/breadcrumbs_on_rails/action_controller.rb
View
8 lib/breadcrumbs_on_rails/action_controller.rb
@@ -14,18 +14,20 @@ module ActionController
included do
extend ClassMethods
helper HelperMethods
- helper_method :add_breadcrumb, :breadcrumbs
+ helper_method :add_breadcrumb, :breadcrumbs_collection
end
protected
def add_breadcrumb(name, path = nil, options = {})
- self.breadcrumbs << Breadcrumbs::Element.new(name, path, options)
+ self.breadcrumbs_collection << Breadcrumbs::Element.new(name, path, options)
end
def breadcrumbs
@breadcrumbs ||= []
end
+ alias_method :breadcrumbs_collection, :breadcrumbs
+
module Utils
@@ -79,7 +81,7 @@ def add_breadcrumb(name, path = nil, filter_options = {})
module HelperMethods
def render_breadcrumbs(options = {}, &block)
- builder = (options.delete(:builder) || Breadcrumbs::SimpleBuilder).new(self, breadcrumbs, options)
+ builder = (options.delete(:builder) || Breadcrumbs::SimpleBuilder).new(self, breadcrumbs_collection, options)
content = builder.render.html_safe
if block_given?
capture(content, &block)
Something went wrong with that request. Please try again.