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

Fix a conditional to handle the null case

Not passing an options hash into sort_link caused it to fail
to look up the link title.

This is because `!args.first.try(:is_a?, Hash)` would return true
if the length of args was 0.

I've simplified the logic to just test if the next parameter in args
is a String (rather than test if it's not a Hash).
This commit is contained in:
Caleb Land 2014-10-06 23:25:21 -04:00 committed by Jon Atack
parent f994542366
commit 31fc131936

View file

@ -58,11 +58,11 @@ module Ransack
end
label_text =
if !args.first.is_a?(Hash)
args.shift.to_s
else
Translate.attribute(field_name, :context => search.context)
end
if String === args.first
args.shift.to_s
else
Translate.attribute(field_name, :context => search.context)
end
options = args.first.is_a?(Hash) ? args.shift.dup : {}
default_order = options.delete :default_order