我尝试关注http://api.rubyonrails.org/classes/ActiveModel/Validator.html,但我应该把
class MyValidator < ActiveModel::Validator
def validate(record)
if some_complex_logic
record.errors[:base] = "This record is invalid"
end
end
private
def some_complex_logic
# ...
end
end