mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
It would take ages to go through all files now and assess all belongs_to associations. So I just declare the old default and then we can move on and apply the new default for the application while these classes still use the old one. All new models will then use the new default which is the goal of this excercise and we can refactor old classes when we touch them anyway.
21 lines
453 B
Ruby
21 lines
453 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class LogEntry < ApplicationRecord
|
|
self.belongs_to_required_by_default = false
|
|
|
|
belongs_to :source, polymorphic: true
|
|
|
|
# Fix for Spree #1767
|
|
# If a payment fails, we want to make sure we keep the record of it failing
|
|
after_rollback :save_anyway
|
|
|
|
def save_anyway
|
|
log = Spree::LogEntry.new
|
|
log.source = source
|
|
log.details = details
|
|
log.save!
|
|
end
|
|
end
|
|
end
|