Sha256: 60cee4121f6403a9bda7a3e4392bfd37c0721fcd780f9038ab5b53b5bbf8c4a3

Contents?: true

Size: 866 Bytes

Versions: 23

Compression:

Stored size: 866 Bytes

Contents

module Searchlogic
  # Active Record is pretty inconsistent with how their SQL is constructed. This
  # method attempts to close the gap between the various inconsistencies.
  module ActiveRecordConsistency
    def self.included(klass)
      klass.class_eval do
        alias_method_chain :merge_joins, :searchlogic
      end
    end
    
    # In AR multiple joins are sometimes in a single join query, and other time they
    # are not. The merge_joins method in AR should account for this, but it doesn't.
    # This fixes that problem.
    def merge_joins_with_searchlogic(*args)
      joins = merge_joins_without_searchlogic(*args)
      joins.collect { |j| j.is_a?(String) ? j.split("  ") : j }.flatten.uniq
    end
  end
end

module ActiveRecord # :nodoc: all
  class Base
    class << self
      include Searchlogic::ActiveRecordConsistency
    end
  end
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
binarylogic-searchlogic-2.1.10 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.11 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.12 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.5 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.6 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.7 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.8 lib/searchlogic/active_record_consistency.rb
binarylogic-searchlogic-2.1.9 lib/searchlogic/active_record_consistency.rb
joost-searchlogic-2.1.5.2 lib/searchlogic/active_record_consistency.rb
joost-searchlogic-2.1.5.3 lib/searchlogic/active_record_consistency.rb
joost-searchlogic-2.1.7.1 lib/searchlogic/active_record_consistency.rb
kazjote-searchlogic-2.1.9.1 lib/searchlogic/active_record_consistency.rb
kazjote-searchlogic-2.1.9.3 lib/searchlogic/active_record_consistency.rb
kazjote-searchlogic-2.1.9 lib/searchlogic/active_record_consistency.rb
skanev-searchlogic-2.1.8.1 lib/searchlogic/active_record_consistency.rb
searchlogic-2.1.5 lib/searchlogic/active_record_consistency.rb
searchlogic-2.1.6 lib/searchlogic/active_record_consistency.rb
searchlogic-2.1.7 lib/searchlogic/active_record_consistency.rb
searchlogic-2.1.8 lib/searchlogic/active_record_consistency.rb
searchlogic-2.1.9 lib/searchlogic/active_record_consistency.rb