every have this problem?

0 views
Skip to first unread message

Terry Lorber

unread,
Jun 24, 2009, 11:56:42 AM6/24/09
to Boston Ruby Group
My model's save and valid? return false, but the errors array is
empty.

Anyone?

/ Terry

Pat Allan

unread,
Jun 24, 2009, 12:00:27 PM6/24/09
to boston-r...@googlegroups.com
Do you have a before_save (or similar) callback that's returning
false? That's usually the cause for me in those situations.

--
Pat

TerryG

unread,
Jun 24, 2009, 12:05:22 PM6/24/09
to Boston Ruby Group
Wow, thanks.

It was actually a before_validation call that did not return true.
That wasted 2 hours....

Thanks again,
Terry

Pat Allan

unread,
Jun 24, 2009, 12:07:19 PM6/24/09
to boston-r...@googlegroups.com
Yeah, I've wasted a few hours on this problem, twice (it was quite a
while between the two, hence why I forgot. Never again! ;)

--
Pat

Brian Cardarella

unread,
Jun 24, 2009, 3:26:42 PM6/24/09
to boston-r...@googlegroups.com
Terry,

   I believe the callback just must not evaluate to false in order to pass through. (maybe nil as well, not certain)


- Brian

Jacob Burkhart

unread,
Jun 24, 2009, 4:48:38 PM6/24/09
to boston-r...@googlegroups.com
Anybody else really hate that about callbacks?

I mean really... I've never had a reason for a before_save or
after_save or before_filter to return false.

I'm either going to render or redirect_to in a before_filter... that
should stop the chain. But everywhere else, I always want the
callback chain to continue.

Like I'll have a model with one after_save defined, that just so
happens to return false sometimes because of whatever it's doing, and
I don't even notice because I'm not thinking about what it returns.
And then a month later I add another after_save to the same model and
am baffled about why it's not running.
Reply all
Reply to author
Forward
0 new messages