I have the following function in my model
after_save :update_status
def update_status
if quantity_received >= quantity
self.received = true
else
self.received = false
end
end
True works great but it doesn’t update to false when set to true. Any idea?
When you’re defining a callback it is very important you do not inadvertently return
false, which is a signal to halt the chain, and that’s what you’re doing here in one case.A re-written version that avoids this problem is:
You can return anything but
false, so the last line could benilortruejust the same.