Open trobrock opened 11 years ago
I also have this issue:
class User < ActiveRecord::Base
state_machine :state, :initial => :idle, :use_transactions => false do
before_transition :idle => :calculating do |obj|
puts "In Before IDLE => CALCULATING"
end
after_transition :idle => :calculating do |obj|
puts "In After IDLE => CALCULATING"
end
event :start do
transition :idle => :calculating
end
event :finish do
transition :calculating => :idle
end
end
end
When I start this I did not expect this to be wrapped in a transaction:
user.fire_events!(:start)
(0.2ms) BEGIN
In Before IDLE => CALCULATING
(0.6ms) UPDATE "users" SET "state" = 'calculating' WHERE "users"."id" = 21
In After IDLE => CALCULATING
(1.4ms) COMMIT
I'd like to see this:
user.fire_events!(:start)
In Before IDLE => CALCULATING
(0.2ms) BEGIN
(0.6ms) UPDATE "users" SET "state" = 'calculating' WHERE "users"."id" = 21
(1.4ms) COMMIT
In After IDLE => CALCULATING
Am I also mis-understanding use_transactions?
I believe this is resolved by: #255
I have something like the following:
I have use_transactions false, because I want the state transitions to be persisted during the callback methods so I can give the client updates on the state of the object. But when I added the use_transactions: false at the top it seems they are still ran within a transaction. Am I misunderstanding what that option does?