1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

Clarify class methods for whitelisting in base.rb

[skip ci]
This commit is contained in:
Jon Atack 2014-09-21 21:05:01 +02:00
parent 0ea6ae2f41
commit 43149202d1

View file

@ -20,27 +20,35 @@ module Ransack
.new(self, name, opts, &block)
end
# 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.
#
def ransackable_attributes(auth_object = nil)
# By default returns all column names and any defined ransackers
# as strings. For overriding with a whitelist of strings.
column_names + _ransackers.keys
end
# Ransackable_associations, by default, returns the names
# of all associations as an array of strings.
# For overriding with a whitelist array of strings.
#
def ransackable_associations(auth_object = nil)
# By default returns the names of all associations as strings.
# For overriding with a whitelist of strings.
reflect_on_all_associations.map { |a| a.name.to_s }
end
# 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.
#
def ransortable_attributes(auth_object = nil)
# By default returns the names of all attributes for sorting.
# For overriding with a whitelist of strings.
ransackable_attributes(auth_object)
end
# Ransackable_scopes, by default, returns an empty array
# i.e. no class methods/scopes are authorized.
# For overriding with a whitelist array of *symbols*.
#
def ransackable_scopes(auth_object = nil)
# By default returns an empty array, i.e. no class methods/scopes
# are authorized. For overriding with a whitelist of symbols.
[]
end