mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
Rails 5 introduced this new class to confine application-specific monkey patches to our models only, and not leak into other libraries using ActiveRecord::Base. https://bigbinary.com/blog/application-record-in-rails-5
19 lines
404 B
Ruby
19 lines
404 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class LogEntry < ApplicationRecord
|
|
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
|