Sha256: a1de9aec428f642b6965c52b339b3cd19e8ee801589bb685c7e46a35b4ca2cfd

Contents?: true

Size: 754 Bytes

Versions: 58

Compression:

Stored size: 754 Bytes

Contents

module Spree
  class UserAddress < Spree::Base
    belongs_to :user, class_name: UserClassHandle.new, foreign_key: "user_id"
    belongs_to :address, class_name: "Spree::Address"

    validates_uniqueness_of :address_id, scope: :user_id
    validates_uniqueness_of :user_id, conditions: -> { active.default }, message: :default_address_exists, if: :default?

    scope :with_address_values, ->(address_attributes) do
      joins(:address).merge(
        Spree::Address.with_values(address_attributes)
      )
    end

    scope :all_historical, -> { unscope(where: :archived) }
    scope :default, -> { where(default: true) }
    scope :active, -> { where(archived: false) }

    default_scope -> { order([default: :desc, updated_at: :desc]) }
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
solidus_core-2.5.2 app/models/spree/user_address.rb
solidus_core-2.5.1 app/models/spree/user_address.rb
solidus_core-2.5.0 app/models/spree/user_address.rb
solidus_core-2.5.0.rc1 app/models/spree/user_address.rb
solidus_core-2.5.0.beta2 app/models/spree/user_address.rb
solidus_core-2.5.0.beta1 app/models/spree/user_address.rb
solidus_core-2.4.2 app/models/spree/user_address.rb
solidus_core-2.3.1 app/models/spree/user_address.rb
solidus_core-2.4.1 app/models/spree/user_address.rb
solidus_core-2.2.2 app/models/spree/user_address.rb
solidus_core-2.1.1 app/models/spree/user_address.rb
solidus_core-2.0.3 app/models/spree/user_address.rb
solidus_core-1.4.2 app/models/spree/user_address.rb
solidus_core-1.3.2 app/models/spree/user_address.rb
solidus_core-1.2.3 app/models/spree/user_address.rb
solidus_core-1.1.4 app/models/spree/user_address.rb
solidus_core-2.4.0 app/models/spree/user_address.rb
solidus_core-2.4.0.rc1 app/models/spree/user_address.rb
solidus_core-2.4.0.beta1 app/models/spree/user_address.rb
solidus_core-2.3.0 app/models/spree/user_address.rb