I can't seem to shake this exception. I have the following code:
class Batch < ApplicationRecord
def self.for_session(session_id, opts)
batch = Batch.where(session_id: session_id.upcase).first_or_initialize
batch.property = opts[:property]
self.session_id = session_id.upcase
I'm not sure how I can change this code to stop getting this exception that I keep getting.
What can I write to fix ActiveRecord::RecordNotUnique?