Sha256: 44936c7989605c1b5d6dfb0ee09b200610655ef3f0537e043155d137ef97157c

Contents?: true

Size: 500 Bytes

Versions: 35

Compression:

Stored size: 500 Bytes

Contents

# frozen_string_literal: true

module Spree
  class Property < Spree::Base
    has_many :product_properties, dependent: :delete_all, inverse_of: :property
    has_many :products, through: :product_properties

    validates :name, :presentation, presence: true

    scope :sorted, -> { order(:name) }

    after_touch :touch_all_products

    self.allowed_ransackable_attributes = %w[name]

    private

    def touch_all_products
      products.update_all(updated_at: Time.current)
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
solidus_core-4.4.1 app/models/spree/property.rb
solidus_core-4.4.0 app/models/spree/property.rb
solidus_core-4.3.4 app/models/spree/property.rb
solidus_core-4.2.4 app/models/spree/property.rb
solidus_core-4.1.5 app/models/spree/property.rb
solidus_core-4.3.3 app/models/spree/property.rb
solidus_core-4.3.2 app/models/spree/property.rb
solidus_core-4.1.4 app/models/spree/property.rb
solidus_core-4.3.1 app/models/spree/property.rb
solidus_core-4.3.0 app/models/spree/property.rb
solidus_core-4.2.3 app/models/spree/property.rb
solidus_core-4.1.3 app/models/spree/property.rb
solidus_core-4.0.4 app/models/spree/property.rb
solidus_core-3.4.6 app/models/spree/property.rb
solidus_core-4.0.3 app/models/spree/property.rb
solidus_core-4.1.2 app/models/spree/property.rb
solidus_core-4.2.2 app/models/spree/property.rb
solidus_core-3.4.5 app/models/spree/property.rb
solidus_core-4.2.1 app/models/spree/property.rb
solidus_core-4.2.0 app/models/spree/property.rb