Sha256: 75f919a0b452786d7e2d54dca78efae61eca11b5da876ae1d4af86ac42fe526f

Contents?: true

Size: 310 Bytes

Versions: 7

Compression:

Stored size: 310 Bytes

Contents

require "active_record"

module ActiveRecord
  module Solr
    def with_query(query)
      results = self.name.constantize.search { fulltext query }.results
      ids = results.inject([]) {|ids, record| ids << record.id}
      self.where(id: ids)
    end
  end
end

ActiveRecord::Base.extend ActiveRecord::Solr

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
refinerycms-solr-1.0.9 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.8 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.7 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.6 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.4 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.3 lib/refinery/solr/active_record.rb
refinerycms-solr-1.0.1 lib/refinery/solr/active_record.rb