Rails 3 - Validates :handle does not equal one of these words
in my app, I allow users to create a handle.
user.rb (:handle)
What I would like to do is have a blacklist of words that can not be used, like "support", "staff", bad words etc...
Is that possible using a validates method in the rails model?
Th开发者_如何学Goanks
Yes, there is validates_exclusion_of
http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000089
Disadvantage: it is sensitive to case, so "bad" and "Bad" are different words.
精彩评论