Sha256: f0a713903e6c034a85cbf8b4fbaa7358c78bc176cb2ae3be755e294974623d25

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'mongoid'
require 'activesearch/mongoid'

Mongoid.configure do |config|
  config.sessions = {:default => {:hosts => ["localhost"], :database => "activesearch_test"}}
end

class MongoidModel
  include Mongoid::Document
  include ActiveSearch::Mongoid
  
  field :title, type: String
  field :text,  type: String
  field :junk,  type: String
  field :special, type: Boolean, default: false
  field :scope_id, type: Integer
  field :tags, type: Array
  
  search_by [:title, :text, :tags, store: [:title, :junk, :scope_id]], unless: :special
end

class AnotherMongoidModel
  include Mongoid::Document
  include ActiveSearch::Mongoid
  
  field :title, type: String
  field :scope_id, type: Integer
  search_by :options_for_search
  
  def options_for_search
    [:title, :text, store: [:title, :virtual, :scope_id]]
  end
  
  def virtual
    "virtual"
  end
end


class LocalizedMongoidModel
  include Mongoid::Document
  include ActiveSearch::Mongoid
  
  field :title, localize: true
  field :special_type
  search_by [:title, store: [:title]]
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activesearch-0.2.0 spec/models/mongoid.rb
activesearch-0.1.3 spec/models/mongoid.rb
activesearch-0.1.2 spec/models/mongoid.rb
activesearch-0.1.1 spec/models/mongoid.rb