Re: Setting a boolean to false in a before_create callback

Gabriel Saravia
Wed, 13 May 2009 17:40:40 -0000

> Also, be careful as if a before_create evaluates to false (as your one
> does) the create won''t actually happen.

a-ha! thanks to both of you!

I had no validations on submitted because I was trying to isolate the
problem (but that doesn''t mean i didn''t want any), but indeed,
it was
the before_create evaluating to false.

final version:

before_validation_on_create :set_defaults

def set_defaults
  self.submitted = false
  return (self.submitted == false)
end


Also, is it just me because I''m too new, or is the
"before_validation_on_create" callback not talked about enough?

Cheers,
-Gabe