jam-cloud/admin/config/initializers/ransack_allow_all.rb

18 lines
507 B
Ruby

# Allow Ransack to search all attributes and associations by default.
# Required for Ransack 4.0+ upgrade.
# Ideally, this should be done per-model for security, but for legacy app upgrade, we enable all.
module RansackAllowAll
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
ActiveSupport.on_load(:active_record) do
extend RansackAllowAll
end