Sha256: 5b8cf9de6bc61fe8b3d6e90fe4a681420263223d6b0e074a04921e21ae119563

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

module Ransack
  module Adapters
    module ActiveRecord
      module Base

        def self.extended(base)
          alias :search :ransack unless base.method_defined? :search
          base.instance_eval do
            class_attribute :_ransackers
            self._ransackers ||= {}
          end
        end

        def ransack(params = {}, options = {})
          Search.new(self, params, options)
        end

        def ransacker(name, opts = {}, &block)
          Ransacker.new(self, name, opts, &block)
        end

        def ransackable_attributes(auth_object)
          column_names + _ransackers.keys
        end

        def ransackable_associations(auth_object)
          reflect_on_all_associations.map {|a| a.name.to_s}
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ransack-0.3.0 lib/ransack/adapters/active_record/3.0/base.rb