Sha256: 62208cdfee5c39acb56f4724b19ffa44a7f0cb184fc896a6d6781b4b7b7fbaa6

Contents?: true

Size: 834 Bytes

Versions: 5

Compression:

Stored size: 834 Bytes

Contents

begin
  require 'sunspot'
  require 'sunspot/rails'
rescue LoadError
  puts "sunspot would allow you to search tags faster, please 'gem install sunspot'"
end

module Tagalong
  def self.enable_sunspot
    Sunspot::Adapters::InstanceAdapter.register(Sunspot::Rails::Adapters::ActiveRecordInstanceAdapter, ActiveRecord::Base)
    Sunspot::Adapters::DataAccessor.register(Sunspot::Rails::Adapters::ActiveRecordDataAccessor, ActiveRecord::Base)
    ActiveRecord::Base.module_eval { include(Sunspot::Rails::Searchable) }
    Tagalong::TagalongTag.searchable do
      integer :tagger_id
      integer :number_of_references
      string :tagger_type
      text :name
    end
  end

  def self.sunspot_enabled?
    Tagalong::TagalongTag.searchable? ? true : false
  end

  def self.reindex_sunspot
    Tagalong::TagalongTag.reindex
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tagalong-0.1.4 lib/tagalong/sunspot.rb
tagalong-0.1.3 lib/tagalong/sunspot.rb
tagalong-0.1.2 lib/tagalong/sunspot.rb
tagalong-0.1.1 lib/tagalong/sunspot.rb
tagalong-0.1.0 lib/tagalong/sunspot.rb