Created
February 10, 2011 14:52
-
-
Save latentflip/820638 to your computer and use it in GitHub Desktop.
Fails validation, but the_model.errors will be empty.
This file contains 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
class TheModel < ActiveRecord::Base | |
def before_validation_on_create | |
#do some stuff | |
setup_defaults | |
end | |
private | |
def setup_defaults | |
self.expense ||= true | |
self.income ||= false | |
end | |
end | |
obj = TheModel.new | |
obj.valid? #=> false | |
obj.errors.count #=> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment