app/models/binda/category.rb in binda-0.0.6 vs app/models/binda/category.rb in binda-0.0.7
- old
+ new
@@ -11,16 +11,20 @@
# Slug
extend FriendlyId
friendly_id :default_slug, use: [:slugged, :finders]
- # CUSTOM METHODS
- # --------------
- # https://github.com/norman/friendly_id/issues/436
+ # Friendly id preference on slug generation
+ #
+ # Method inherited from friendly id
+ # @see https://github.com/norman/friendly_id/issues/436
def should_generate_new_friendly_id?
slug.blank? || name_changed?
end
+ # Set slug name
+ #
+ # It generates 4 possible slugs before falling back to FriendlyId default behaviour
def default_slug
[ "#{ self.structure.name }-#{ self.name }",
"#{ self.structure.name }-#{ self.name }-1",
"#{ self.structure.name }-#{ self.name }-2",
"#{ self.structure.name }-#{ self.name }-3" ]