We have grape API but I wonder if we can wrap it with active record transaction every time we do request.
In active record to do transaction, we can do something like this:
ActiveRecord::Base.transaction do
# do select
# do update
# do insert
end
How can I wrap it into grape API?
As far as i know, in Grape API we can implement before method and after method.
class API < Grape::API
before do
# ????? Need to implement code here to begin active record transaction
# this suppose to begin active record transaction
end
after do
# ????? Need to implement code here to end active record transaction
# this suppose to end active record transaction
end
end