module Ransack::Adapters::ActiveRecord::Base
Public Class Methods
extended(base)
click to toggle source
# File lib/ransack/adapters/active_record/base.rb, line 6 def self.extended(base) alias :search :ransack unless base.respond_to? :search base.class_eval do class_attribute :_ransackers self._ransackers ||= {} end end
Public Instance Methods
ransack(params = {}, options = {})
click to toggle source
# File lib/ransack/adapters/active_record/base.rb, line 14 def ransack(params = {}, options = {}) Search.new(self, params, options) end
ransackable_associations(auth_object = nil)
click to toggle source
Ransackable_associations, by default, returns the names of all associations as an array of strings. For overriding with a whitelist array of strings.
# File lib/ransack/adapters/active_record/base.rb, line 35 def ransackable_associations(auth_object = nil) reflect_on_all_associations.map { |a| a.name.to_s } end
ransackable_attributes(auth_object = nil)
click to toggle source
Ransackable_attributes, by default, returns all column names and any defined ransackers as an array of strings. For overriding with a whitelist array of strings.
# File lib/ransack/adapters/active_record/base.rb, line 27 def ransackable_attributes(auth_object = nil) column_names + _ransackers.keys end
ransackable_scopes(auth_object = nil)
click to toggle source
Ransackable_scopes, by default, returns an empty array i.e. no class methods/scopes are authorized. For overriding with a whitelist array of symbols.
# File lib/ransack/adapters/active_record/base.rb, line 51 def ransackable_scopes(auth_object = nil) [] end
ransacker(name, opts = {}, &block)
click to toggle source
# File lib/ransack/adapters/active_record/base.rb, line 18 def ransacker(name, opts = {}, &block) self._ransackers = _ransackers.merge name.to_s => Ransacker .new(self, name, opts, &block) end
ransortable_attributes(auth_object = nil)
click to toggle source
Ransortable_attributes, by default, returns the names of all attributes available for sorting as an array of strings. For overriding with a whitelist array of strings.
# File lib/ransack/adapters/active_record/base.rb, line 43 def ransortable_attributes(auth_object = nil) ransackable_attributes(auth_object) end