Validate method called 2 times when saving

Hello,

when I call the save! method in one of my model objects, the validate
method in that same object is called 2 times. Why is this? It doesn’t
happen when I call save (instead of save!), and looking at the source
code of these Rails methods, I don’t understand how ‘validate’ can be
called 2 times when invoking save! and only 1 time when invoking save,
as the code for save! is simply…

save || raise(RecordNotSaved)

Do you know what’s happening here?

xavi

On 11/24/06, xavi [email protected] wrote:

when I call the save! method in one of my model objects, the validate
method in that same object is called 2 times. Why is this? It doesn’t
happen when I call save (instead of save!), and looking at the source
code of these Rails methods, I don’t understand how ‘validate’ can be
called 2 times when invoking save! and only 1 time when invoking save,
as the code for save! is simply…

Because both save and save! validate, and save! calls save.

save! validates once in 1.2.

jeremy

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs