Skip to content

Commit cc624b9

Browse files
authored
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.
1 parent 14495bb commit cc624b9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/ransack/context.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,16 @@ def unpolymorphize_association(str)
152152
end
153153

154154
def ransackable_alias(str)
155-
klass._ransack_aliases.fetch(str, str)
155+
klass._ransack_aliases.fetch(str, klass._ransack_aliases.fetch(str.to_sym, str))
156156
end
157157

158158
def ransackable_attribute?(str, klass)
159-
klass.ransackable_attributes(auth_object).include?(str) ||
160-
klass.ransortable_attributes(auth_object).include?(str)
159+
klass.ransackable_attributes(auth_object).any? { |s| s.to_sym == str.to_sym } ||
160+
klass.ransortable_attributes(auth_object).any? { |s| s.to_sym == str.to_sym }
161161
end
162162

163163
def ransackable_association?(str, klass)
164-
klass.ransackable_associations(auth_object).include? str
164+
klass.ransackable_associations(auth_object).any? { |s| s.to_sym == str.to_sym }
165165
end
166166

167167
def ransackable_scope?(str, klass)

0 commit comments

Comments
 (0)