I’m a fan of ActiveRecord’s callbacks, as i see it a clean way to get things done in the life-cycle of a model instance. Yet, today a couple of us just tripped over the following:
1 2 3 4 5 6 7 8 9 10 |
|
The problem with Thing#reset_pretty_flag
is that in the unfortunate
case that thing isn’t pretty, its creation fails. Why ?? Cos when thing
isn’t pretty, a false is returned, & this halts the create executation
chain. The workaround is therefore to return a true always:
1 2 3 4 |
|
To learn more, i strongly encourage a good read on ActiveRecord’s callbacks