I know this has been mentioned before, but could we do something about validate and validates?
Having two methods with such similar names that do similar things but in a totally different way is extremely confusing. What’s more, if you do use validate instead of validates by mistake, no exceptions are raised and MyModel.valid? will return true.
I have trouble remembering which one I should be calling, and I’ve been working with Rails for years now. I can’t imagine how confused a novice programmer would be…
Perhaps renaming validate to something like validates_with would be the way to go (with proper deprecation warnings, of course)?
Whoops, not validates_with since that already exists… Something else (what, I’m not sure).
That wouldn’t really solve the problem since it would change the validate/validates situation to validate_with/validates_with.
exactly my point, I think we should add
validates_with to the
Is there are a reason we couldn’t put
options.assert_valid_keys :on, :allow_nil, :allow_blank, :if, :unless as the second line of the
Then if you intend to call
validates but mistakenly call
validate you would receive an ArgumentError. If you use them wrong the other way around, it will already give ArgumentError.