Does anyone know how to do a blacklist in ruby?

ruby
rails

#1

I need to reject a few words when a user creates a comment, I need to know how I can do this without using a gem :frowning:


#2
words = "a few words with some to block and prevent bad words"
blacklist = %w[bad block prevent]
words.split.delete_if {|word| blacklist.include? word }.join(' ')
# => "a few words with some to and words"