nonrecursive-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-05 13:20 UTC
unexpected behavior of before_validation
Today I found these comments in active record''s callbacks.rb file: # If the returning value of a before_validation callback can be evaluated to false, the process will be aborted and Base#save will return false. # If Base#save! is called it will raise a RecordNotSave error. # Nothing will be appended to the errors object. This caused me a lot of frustration earlier when I was trying to get a model with the following code to save: before_validation :ensure_boolean_value_for_finalized private def ensure_boolean_value_for_finalized self.finalized = false unless self.finalized end I''m wondering why before_validation will abort the process of saving. My conception of before_validation was that its purpose was only to prepare the model object for validation, and that its purpose was *not* to do pre-validation validation. It''s not a huge deal - I''m just wondering what the logic behind before_validation''s behavior is. Daniel http://www.hallwaytesting.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- before before_validation callback
- Problems with before_validation
- [Sentry]-before_validation(model) not working for crypted-attribute?
- before_create is after_validatation :on => :create , when it should be before_validation :on => :create
- callback object problem