mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #13656 from pacodelaluna/replace-alias-attribute-with-alias-method
Replace alias_attribute with alias_method
This commit is contained in:
@@ -8,6 +8,10 @@ module Api
|
||||
include AddressTransformation
|
||||
include ExtraFields
|
||||
|
||||
wrap_parameters :customer, include:
|
||||
Customer.attribute_names +
|
||||
[:billing_address, :shipping_address]
|
||||
|
||||
skip_authorization_check only: :index
|
||||
|
||||
before_action :authorize_action, only: [:show, :update, :destroy]
|
||||
@@ -88,7 +92,8 @@ module Api
|
||||
attributes = params.require(:customer).permit(
|
||||
:email, :enterprise_id,
|
||||
:code, :first_name, :last_name,
|
||||
:billing_address, shipping_address: [
|
||||
:billing_address,
|
||||
shipping_address: [
|
||||
:phone, :latitude, :longitude,
|
||||
:first_name, :last_name,
|
||||
:street_address_1, :street_address_2,
|
||||
|
||||
@@ -25,11 +25,13 @@ class Customer < ApplicationRecord
|
||||
before_destroy :update_orders_and_delete_canceled_subscriptions
|
||||
|
||||
belongs_to :bill_address, class_name: "Spree::Address", optional: true
|
||||
alias_attribute :billing_address, :bill_address
|
||||
alias_method :billing_address, :bill_address
|
||||
alias_method :billing_address=, :bill_address=
|
||||
accepts_nested_attributes_for :bill_address
|
||||
|
||||
belongs_to :ship_address, class_name: "Spree::Address", optional: true
|
||||
alias_attribute :shipping_address, :ship_address
|
||||
alias_method :shipping_address, :ship_address
|
||||
alias_method :shipping_address=, :ship_address=
|
||||
accepts_nested_attributes_for :ship_address
|
||||
|
||||
validates :code, uniqueness: { scope: :enterprise_id, allow_nil: true }
|
||||
|
||||
@@ -35,10 +35,12 @@ module Spree
|
||||
belongs_to :created_by, class_name: "Spree::User", optional: true
|
||||
|
||||
belongs_to :bill_address, class_name: 'Spree::Address', optional: true
|
||||
alias_attribute :billing_address, :bill_address
|
||||
alias_method :billing_address, :bill_address
|
||||
alias_method :billing_address=, :bill_address=
|
||||
|
||||
belongs_to :ship_address, class_name: 'Spree::Address', optional: true
|
||||
alias_attribute :shipping_address, :ship_address
|
||||
alias_method :shipping_address, :ship_address
|
||||
alias_method :shipping_address=, :ship_address=
|
||||
|
||||
has_many :state_changes, as: :stateful, dependent: :destroy
|
||||
has_many :line_items, -> {
|
||||
|
||||
@@ -24,8 +24,10 @@ class Subscription < ApplicationRecord
|
||||
has_many :proxy_orders, dependent: :destroy
|
||||
has_many :orders, through: :proxy_orders
|
||||
|
||||
alias_attribute :billing_address, :bill_address
|
||||
alias_attribute :shipping_address, :ship_address
|
||||
alias_method :billing_address, :bill_address
|
||||
alias_method :billing_address=, :bill_address=
|
||||
alias_method :shipping_address, :ship_address
|
||||
alias_method :shipping_address=, :ship_address=
|
||||
|
||||
accepts_nested_attributes_for :subscription_line_items, allow_destroy: true
|
||||
accepts_nested_attributes_for :bill_address, :ship_address
|
||||
|
||||
@@ -79,9 +79,6 @@ Rails.application.configure do
|
||||
|
||||
"Passing the class as positional argument",
|
||||
|
||||
# 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. (called from initialize at app/models/spree/order.rb:188)
|
||||
"alias_attribute with non-attribute targets will raise",
|
||||
|
||||
# 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.
|
||||
"model aliases",
|
||||
|
||||
|
||||
Reference in New Issue
Block a user