I know that usually when people say 'i think i found a bug in
rails/ruby' they've done something dumb. I'm wondering if this is the
case here, but this does seem like a genuine rails bug to me.
In my user model i have a few different before_create callbacks. In one
of them, if it happens to return false (just because the last statement
in it evaluated to false), then the saving gets blocked - i can see the
db transaction rolling back. However, this doesn't affect the results
of calling .valid? on the object, so i get this situation:
This has caused me a considerable amount of beard-tugging to track this
Now, i was under the impression that before_create doesn't care what's
returned by the method it calls, and for my other before_save callbacks
it doesn't seem to make any difference - just this one. It's definitely
the return value because if i put 'true' as the last line of the
callback method then everything is fine. I change it to 'false' and
everything's not-fine again.
I'm in rails 2.2.2.
Can anyone shed any light on this?