Answer the question
In order to leave comments, you need to log in
How do you know if a Rails transaction is open?
def some_usefull_regular_action
raise 'method must call with transaction. Rollback' unless transaction.open?
operation A
operation B
end
Controller
def my_action
ActiveRecord.transaction do
some_usefull_regular_action
()
operation C
end
end
Ps I'm writing from my phone.
Answer the question
In order to leave comments, you need to log in
def some_usefull_regular_action
raise 'method must call with transaction. Rollback' unless ActiveRecord::Base.connection.transaction_open?
operation A
operation B
end
def my_action
ActiveRecord::Base.connection.transaction do
some_usefull_regular_action()
operation C
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question