Sha256: 9ac907549dd533dd0e0d654cca346281abf9c5b8a7b01c05f78c58caa3c97613
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require 'ransack/context' require 'ransack/adapters/active_record/3.1/context' require 'polyamorous' module Ransack module Adapters module ActiveRecord class Context < ::Ransack::Context # Redefine a few things that have changed with 3.2. def initialize(object, options = {}) super @arel_visitor = @engine.connection.visitor end def type_for(attr) return nil unless attr && attr.valid? name = attr.arel_attribute.name.to_s table = attr.arel_attribute.relation.table_name unless @engine.connection.table_exists?(table) raise "No table named #{table} exists" end @engine.connection.schema_cache.columns_hash[table][name].type end def evaluate(search, opts = {}) viz = Visitor.new relation = @object.where(viz.accept(search.base)) if search.sorts.any? relation = relation.except(:order).order(viz.accept(search.sorts)) end opts[:distinct] ? relation.uniq : relation end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ransack-0.7.0 | lib/ransack/adapters/active_record/context.rb |
ransack_ffcrm-0.6.0 | lib/ransack/adapters/active_record/context.rb |