Sha256: e05df22ead63f25fe187df9e072d3d1cbc7c481915b0f76fb38ccd86dae71694

Contents?: true

Size: 661 Bytes

Versions: 22

Compression:

Stored size: 661 Bytes

Contents

module Spree
  module OrderedPropertyValueList
    extend ActiveSupport::Concern

    included do
      validates :property, presence: true
      validates_with Spree::Validations::DbMaximumLengthValidator, field: :value

      default_scope -> { order(:position) }
    end

    # virtual attributes for use with AJAX autocompletion
    def property_name
      property.name if property
    end

    def property_name=(name)
      unless name.blank?
        unless property = Spree::Property.find_by(name: name)
          property = Spree::Property.create(name: name, presentation: name)
        end
        self.property = property
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
solidus_core-2.5.2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.5.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.5.0 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.5.0.rc1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.5.0.beta2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.5.0.beta1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.4.2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.4.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.2.2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.4.0 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.4.0.rc1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.4.0.beta1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.0 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.0.rc3 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.0.rc2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.0.rc1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.3.0.beta1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.2.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-2.2.0 app/models/concerns/spree/ordered_property_value_list.rb