If I assign booleans in my callbacks, does it affect transactions? I suspect the assignment of false also return self.assigned in case below and thus breaks my transaction. Is this the case?
before_create :set_default_values
def set_default_values
self.finished = false
self.assigned = false
end
Yes, this does affect the transactions. Here’s the description from the official Rails doc:
I would just set these to
:default => falsein your migration file for setting up this table or columns. This definitely be easier.Here’s the callbacks doc:
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html