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
1 changed files with 5 additions and 5 deletions

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