should help you out Kohana 3 apparently has transaction methods, although they do not appear to be documented. See this link Transactions are database-level, so anything you do between a start and a commit is part of the transaction, no matter how many tables are involved.
Rails updating object creating two database transactions
seems to work fine The :create_salesforce_loan_application is being called twice because the object is updated twice in the process, maybe by other callback or gem such as Paperclip. A better approach to this would be to use after_save instead of after_commit, checking if :status attribute changed.
class LoanApplication < ActiveRecord:Base
after_save :create_salesforce_loan_application, on: :update
if status_changed? && status == 'active'
puts "create salesforce function running"
# Updating business column
updating multiple database tables in one PUT/PATCH
will help you Ok, I have found a solution, apparently it was super simple but if someone has similar confusion here's the answer: Just get the user with username which is set in nested object like this.
for buy_data in buy:
buy_history_s = BuyHistory(**buy_data)
user = User.objects.get(username=buy_history_s.username)
if buy_history_s.time is None:
buy_history_s.time = datetime.datetime.now()