Skip to content

Commit

Permalink
Remove deprecated usage of alias_attributes
Browse files Browse the repository at this point in the history
This commit removes the following deprecations:

DEPRECATION WARNING: Spree::Order model aliases `bill_address`, but `bill_address` is not an attribute. Starting in Rails 7.2, alias_attribute with non-attribute targets will raise. Use `alias_method :billing_address, :bill_address` or define the method manually.

DEPRECATION WARNING: Spree::Order model aliases `ship_address`, but `ship_address` is not an attribute. Starting in Rails 7.2, alias_attribute with non-attribute targets will raise. Use `alias_method :shipping_address, :ship_address` or define the method manually.

DEPRECATION WARNING: Spree::CreditCard model aliases `cc_type` and has a method called `cc_type=` defined. Starting in Rails 7.2 `brand=` will not be calling `cc_type=` anymore. You may want to additionally define `brand=` to preserve the current behavior.
  • Loading branch information
kennyadsl committed Dec 6, 2023
1 parent 2ceedca commit d85e5e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions core/app/models/spree/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def cc_type=(type)
end
end

def brand=(type)
cc_type = type
end

# Sets the last digits field based on the assigned credit card number.
def set_last_digits
self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..)
Expand Down
5 changes: 2 additions & 3 deletions core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ class CannotRebuildShipments < StandardError; end
# Customer info
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address', optional: true
alias_attribute :billing_address, :bill_address

alias_method :billing_address, :bill_address
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address', optional: true
alias_attribute :shipping_address, :ship_address
alias_method :billing_address, :bill_address
alias_attribute :ship_total, :shipment_total

belongs_to :store, class_name: 'Spree::Store', optional: true
Expand Down

0 comments on commit d85e5e5

Please sign in to comment.