Sha256: e63cda4d531489576e6ad8cb654fab3b031c88e41435e0baef1f01df9113a397

Contents?: true

Size: 839 Bytes

Versions: 16

Compression:

Stored size: 839 Bytes

Contents

module Ransack
  module Adapters
    module ActiveRecord
      module Base

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

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

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

        def ransackable_attributes(auth_object = nil)
          column_names + _ransackers.keys
        end

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

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
ransack-1.0.0 lib/ransack/adapters/active_record/base.rb
ransack-0.7.2 lib/ransack/adapters/active_record/base.rb
ransack-0.7.1 lib/ransack/adapters/active_record/base.rb
ransack_ffcrm-0.7.1 lib/ransack/adapters/active_record/base.rb
ransack-0.7.0 lib/ransack/adapters/active_record/base.rb
ransack_ffcrm-0.6.0 lib/ransack/adapters/active_record/base.rb
ransack-0.6.0 lib/ransack/adapters/active_record/base.rb
ransack-0.5.8 lib/ransack/adapters/active_record/base.rb
ransack-0.5.7 lib/ransack/adapters/active_record/base.rb
ransack-0.5.6 lib/ransack/adapters/active_record/base.rb
ransack-0.5.5 lib/ransack/adapters/active_record/base.rb
ransack-0.5.4 lib/ransack/adapters/active_record/base.rb
ransack-0.5.3 lib/ransack/adapters/active_record/base.rb
ransack-0.5.2 lib/ransack/adapters/active_record/base.rb
ransack-0.5.1 lib/ransack/adapters/active_record/base.rb
ransack-0.5.0 lib/ransack/adapters/active_record/base.rb