Sha256: f95ae19d07b1b0cb5aca56f9d71f8b650c58f8779c9ec75904e3bedff8ce92a6

Contents?: true

Size: 447 Bytes

Versions: 32

Compression:

Stored size: 447 Bytes

Contents

module Spree
  module SingleStoreResource
    extend ActiveSupport::Concern

    included do
      validate :ensure_store_association_is_not_changed

      scope :for_store, ->(store) { where(store_id: store.id) }
    end

    protected

    def ensure_store_association_is_not_changed
      if store_id_changed? && persisted?
        errors.add(:store, Spree.t('errors.messages.store_association_can_not_be_changed'))
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
spree_core-4.10.1 app/models/concerns/spree/single_store_resource.rb
spree_core-4.10.0 app/models/concerns/spree/single_store_resource.rb
spree_core-4.9.0 app/models/concerns/spree/single_store_resource.rb
spree_core-4.8.3 app/models/concerns/spree/single_store_resource.rb
spree_core-4.8.2 app/models/concerns/spree/single_store_resource.rb
spree_core-4.7.3 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.6 app/models/concerns/spree/single_store_resource.rb
spree_core-4.5.5 app/models/concerns/spree/single_store_resource.rb
spree_core-4.3.3 app/models/concerns/spree/single_store_resource.rb
spree_core-4.4.1 app/models/concerns/spree/single_store_resource.rb
spree_core-4.5.4 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.5 app/models/concerns/spree/single_store_resource.rb
spree_core-4.7.2 app/models/concerns/spree/single_store_resource.rb
spree_core-4.7.1 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.4 app/models/concerns/spree/single_store_resource.rb
spree_core-4.7.0 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.3 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.2 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.1 app/models/concerns/spree/single_store_resource.rb
spree_core-4.6.0 app/models/concerns/spree/single_store_resource.rb