Created
August 27, 2010 02:38
-
-
Save huacnlee/552676 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
class String | |
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 | |
Ruby1.8.7 > "aaa".remove_html_tags() | |
Ruby1.8.7 > "aaa".safe_slug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment