From cc624b97930af59c0fbe5f1226951684f8433810 Mon Sep 17 00:00:00 2001 From: Mark Huk Date: Tue, 21 Nov 2023 10:21:14 +0100 Subject: [PATCH] Update context to support both %i and %w for ransachable_* methods (#1459) Currently `ransackable_scopes` allows both, and for some reason the rest expects %w only. --- lib/ransack/context.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ransack/context.rb b/lib/ransack/context.rb index 90ab3e11..dbb99666 100644 --- a/lib/ransack/context.rb +++ b/lib/ransack/context.rb @@ -152,16 +152,16 @@ def unpolymorphize_association(str) end def ransackable_alias(str) - klass._ransack_aliases.fetch(str, str) + klass._ransack_aliases.fetch(str, klass._ransack_aliases.fetch(str.to_sym, str)) end def ransackable_attribute?(str, klass) - klass.ransackable_attributes(auth_object).include?(str) || - klass.ransortable_attributes(auth_object).include?(str) + klass.ransackable_attributes(auth_object).any? { |s| s.to_sym == str.to_sym } || + klass.ransortable_attributes(auth_object).any? { |s| s.to_sym == str.to_sym } end def ransackable_association?(str, klass) - klass.ransackable_associations(auth_object).include? str + klass.ransackable_associations(auth_object).any? { |s| s.to_sym == str.to_sym } end def ransackable_scope?(str, klass)