Skip to content

Instantly share code, notes, and snippets.

@amcooper
Created November 30, 2016 22:50
Show Gist options
  • Save amcooper/c2ecee11a57d26d9db7dc93d02471954 to your computer and use it in GitHub Desktop.
Save amcooper/c2ecee11a57d26d9db7dc93d02471954 to your computer and use it in GitHub Desktop.
New code for title slugging
class Project
attr_accessor :title
def slug
@title.strip.downcase.gsub(/(&|&)/, ' and ').gsub(/[\s\.\/\\]/, '-').gsub(/[^\w-]/, '').gsub(/[-_]{2,}/, '-').gsub(/^[-_]/, '').gsub(/[-_]$/, '')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment