The app finds or initializes by an attribute:
booking = Booking.where(deal_id: params["id"]).first_or_initialize
Then updates some additional attributes
if booking.update!(
guests: guests,
names: names,
time: time)
This code gives me the error
Validation failed: Deal has already been taken
The validation code is
validates_uniqueness_of :deal_id, allow_blank: true, scope: [:experience_id, :time], unless: -> {deal_id.zero? }
Why is it giving a "has already been taken" error when first it does first_or_initialize?
Thanks