Sha256: 3af3deca77cc2bb56eef7d37d7f63af00ec6eea7cfcb5dc1514d5a71622cd1bd
Contents?: true
Size: 896 Bytes
Versions: 7
Compression:
Stored size: 896 Bytes
Contents
module Ransack module Adapters module ActiveRecord module Base def ransack(params = {}, options = {}) old_base_connection = ::ActiveRecord::Base.method(:connection) connection_obj = connection ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj } Search.new(self, params, options) ensure ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection) end end end end class Search def result(opts = {}) old_base_connection = ::ActiveRecord::Base.method(:connection) connection_obj = @context.klass.connection ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj } @context.evaluate(self, opts) ensure ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection) end end end
Version data entries
7 entries across 7 versions & 1 rubygems