-
-
Save huobazi/973844 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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