Skip to content

Commit

Permalink
Remove ApplicationRecord
Browse files Browse the repository at this point in the history
This gem redefines the host apps ApplicationRecord class,
which is very wrong!

We introduce a namespaced BaseRecord and set the correct
table_name_prefix on that class.
  • Loading branch information
tvdeyen committed Dec 17, 2024
1 parent 74fdae8 commit 16360e6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 0 additions & 5 deletions app/models/application_record.rb

This file was deleted.

8 changes: 8 additions & 0 deletions app/models/solidus_braintree/base_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

module SolidusBraintree
class BaseRecord < ::Spree::Base
self.abstract_class = true
self.table_name_prefix = 'solidus_paypal_braintree_'
end
end
2 changes: 1 addition & 1 deletion app/models/solidus_braintree/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module SolidusBraintree
class Configuration < ::Spree::Base
class Configuration < BaseRecord
self.table_name = "solidus_paypal_braintree_configurations"

PAYPAL_BUTTON_PREFERENCES = {
Expand Down
4 changes: 1 addition & 3 deletions app/models/solidus_braintree/customer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true

module SolidusBraintree
class Customer < ApplicationRecord
self.table_name = "solidus_paypal_braintree_customers"

class Customer < BaseRecord
belongs_to :user, class_name: ::Spree::UserClassHandle.new, optional: true
has_many :sources, class_name: "SolidusBraintree::Source", inverse_of: :customer, dependent: :destroy
end
Expand Down

0 comments on commit 16360e6

Please sign in to comment.