0

I am using ruby's aasm gem to implement a state machine and want to update a different column apart from the state itself during one of the transitions. For example:

event :transact do
  # This will make two calls to the database. Ideally we should be able to 
  # change the custom_column flag and the state in one call.
  transitions from: [:open], to: :closed, after: Proc.new { update!(custom_column: 'yeah!') }
end

After this, both state and custom_column are updated, but that required two calls to the database.

Is there any way to make both modifications in a single call?

0 Answers0