Sha256: c54f16ae7100bda7d30b43b00014c50e6860a43d2e568ff15ea1f37116da67b0

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

class Product
  include Mongoid::Document
  include Mongoid::Search
  include Mongoid::Attributes::Dynamic if ::Mongoid::VERSION >= '4'

  field :brand
  field :name
  field :unit
  field :measures, type: Array
  field :attrs, type: Array
  field :info, type: Hash

  has_many :tags
  if Mongoid::Compatibility::Version.mongoid6_or_newer?
    belongs_to  :category, required: false
  else
    belongs_to  :category
  end
  embeds_many :subproducts

  search_in :brand, :name, :outlet, :attrs, tags: :name, category: %i[name description],
                                            subproducts: %i[brand name], info: %i[summary description]
  search_in :unit, :measures, index: :_unit_keywords
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid_search-0.4.0 spec/models/product.rb
mongoid_search-0.3.6 spec/models/product.rb