Sha256: c47ca24b40802dbcd240f0970a1f1ce122eb7e3ba9c767d7fbd380f3b0a0c871

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

class Product < ActiveRecord::Base
  belongs_to :category, class_name: 'ProductCategory', inverse_of: :products, optional: true

  has_many :variations, class_name: 'ProductVariation', inverse_of: :product

  validates :title, presence: true

  searchable do |o|
    o.relation :variations, :title, :stock_status

    o.attribute :title
    o.attribute :description
    o.attribute :rating, unkeyed: false
    o.attribute :title_length, unkeyed: false do
      Arel::Nodes::NamedFunction.new('LENGTH', [
        arel_table[:title]
      ])
    end

    o.attribute :category, :category_id
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pursuit-0.4.2 spec/internal/app/models/product.rb
pursuit-0.4.1 spec/internal/app/models/product.rb
pursuit-0.4.0 spec/internal/app/models/product.rb
pursuit-0.3.2 spec/internal/app/models/product.rb