You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# bad - job may perform earlier than the transaction is committedUser.transactiondousers_params.eachdo |user_params|
user=User.create!(user_params)NotifyUserJob.perform_later(user)endend# goodusers=User.transactiondousers_params.mapdo |user_params|
User.create!(user_params)endendusers.each{ |user| NotifyUserJob.perform_later(user)}
The text was updated successfully, but these errors were encountered:
Reference: https://github.com/toptal/active-job-style-guide#mind-transactions
Background processing of a scheduled job may happen sooner than you expect. Make sure to only schedule jobs when the transaction has been committed.
The text was updated successfully, but these errors were encountered: