Skip to content

Instantly share code, notes, and snippets.

@dpritchett
Created February 7, 2014 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpritchett/8871014 to your computer and use it in GitHub Desktop.
Save dpritchett/8871014 to your computer and use it in GitHub Desktop.
# lib/spree/core/permalinks_decorator.rb
module Spree
module Core
module Permalinks
# <client> asked to have permalink generation not use the word 'slash' where
# a '/' is present. Now we just let Spree generate it (via StringEx fwiw)
# and then strip it out.
#
def self.generate_url_slug(name)
slashes = /(-slash|-slash-|slash-)/
name.to_s.to_url.gsub(slashes, '-'). # remove the word slash
gsub(/-+/, '-'). # compact repeated slashes to one
gsub(/(^-|-$)/, '') # remove leading/trailing slashes
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment