Sha256: 1b9db51182d2343ecf8c88033dd89f45d57aae9b2b36321a2dc504f8c32b4b98
Contents?: true
Size: 952 Bytes
Versions: 1
Compression:
Stored size: 952 Bytes
Contents
# frozen_string_literal: true class ProductVariation < ApplicationRecord belongs_to :product enum stock_status: { in_stock: 1, low_stock: 2, out_of_stock: 3 } validates :title, presence: true validates :currency, presence: true validates :amount, presence: true, numericality: true def self.predicate_search @predicate_search ||= Pursuit::PredicateSearch.new( left_outer_joins(:product).group(:id) ) do permit_attribute :title permit_attribute :stock_status permit_attribute :currency permit_attribute :amount permit_attribute :product, Product.arel_table[:id] permit_attribute :product_title, Product.arel_table[:title] end end def self.term_search @term_search ||= Pursuit::TermSearch.new(all) do search_attribute :title end end def self.search(query) predicate_search.apply(query) rescue Parslet::ParseFailed term_search.apply(query) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pursuit-1.0.1 | spec/internal/app/models/product_variation.rb |