Skip to content

Instantly share code, notes, and snippets.

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 huobazi/973844 to your computer and use it in GitHub Desktop.
Save huobazi/973844 to your computer and use it in GitHub Desktop.
module StringExtensions
def remove_html_tags()
self.gsub(/<.+?>/, "")
end
# clear unsafe char with url slug
def safe_slug(spliter = '-')
@slug = self
if @slug.blank?
Guid.new
@slug = Guid.generate
end
@slug.gsub(/[^a-zA-Z\-0-9]/,spliter).downcase
end
end
String.send :include,StringExtensions
Ruby1.9.2 > "aaa".remove_html_tags()
Ruby1.9.2 > "aaa".safe_slug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment