From 31fc131936e0e5d09b4e26f2c14ecd13160b8726 Mon Sep 17 00:00:00 2001 From: Caleb Land Date: Mon, 6 Oct 2014 23:25:21 -0400 Subject: [PATCH] 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). --- lib/ransack/helpers/form_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ransack/helpers/form_helper.rb b/lib/ransack/helpers/form_helper.rb index 99f4c82..b949b2b 100644 --- a/lib/ransack/helpers/form_helper.rb +++ b/lib/ransack/helpers/form_helper.rb @@ -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