Created
July 27, 2011 22:16
-
-
Save courtsimas/1110495 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
////in questions#create action | |
if filter_profanity( @question.body, I18n.t(:bad_words).split( /, */ ) ).present? | |
redirect_to @question, :alert => I18n.t(:bad_words_warning) and return | |
end | |
///in the application controller | |
def filter_profanity( check_str = "", prohibited_words = [] ) | |
return check_str.downcase.gsub!(/[^a-z]/, " ").split(" ").uniq.map { |w| w if prohibited_words.include?( w ) }.compact! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment