Sha256: 61cbbcda874cf7a49df725d6f1d2158b35f58f5bf1b829e555ab6310dbbff632

Contents?: true

Size: 691 Bytes

Versions: 15

Compression:

Stored size: 691 Bytes

Contents

module Spree
  module OrderedPropertyValueList
    extend ActiveSupport::Concern

    included do
      acts_as_list

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

      default_scope -> { order(:position) }

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
solidus_core-1.2.3 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.4 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.3 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.0 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.0.rc2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.0.rc1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.2.0.beta1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.0 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.0.pre2 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.0.pre1 app/models/concerns/spree/ordered_property_value_list.rb
solidus_core-1.1.0.beta1 app/models/concerns/spree/ordered_property_value_list.rb