Module: ActsAsFulltextable::FulltextableClassMethods

Defined in:
lib/acts_as_fulltextable.rb

Instance Method Summary collapse

Instance Method Details

#find_fulltext(query, options = {}) ⇒ Object

Performs full-text search for objects of this class. It takes three options:

  • limit: maximum number of rows to return. Defaults to 10.

  • offset: offset to apply to query. Defaults to 0.

  • page: only available with will_paginate plugin installed.

  • active_record: wether a ActiveRecord objects should be returned or an Array of [class_name, id]



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/acts_as_fulltextable.rb', line 46

def find_fulltext(query, options = {})
  default_options = {:active_record => true}
  options = default_options.merge(options)
  unless options[:page]
    options = {:limit => 10, :offset => 0}.merge(options)
  end
  options[:only] = self.to_s.underscore.to_sym # Only look for object belonging to this class
  # Pass from what class search is invoked.
  options[:search_class] = Kernel.const_get(self.to_s)

  FulltextRow.search(query, options)
end

#fulltext_fieldsObject



35
36
37
# File 'lib/acts_as_fulltextable.rb', line 35

def fulltext_fields
  self.fulltext_options[:fields]
end