From af7f4877293e26eb1fb2909f33c1ae263080f150 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 12 Sep 2014 17:59:11 +0300 Subject: [PATCH] fix attribute translation for activerecord using STI --- lib/ransack/translate.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ransack/translate.rb b/lib/ransack/translate.rb index 079e0e1..04de4f8 100644 --- a/lib/ransack/translate.rb +++ b/lib/ransack/translate.rb @@ -81,13 +81,16 @@ module Ransack :"#{associated_class.i18n_scope}.attributes.#{ i18n_key(associated_class)}.#{attr_name}" else - :"#{context.klass.i18n_scope}.attributes.#{ - i18n_key(context.klass)}.#{attr_name}" + context.klass.ancestors.select do |k| + k.respond_to?(:model_name) + end.collect do |k| + :"#{k.i18n_scope}.attributes.#{i18n_key(k)}.#{attr_name}" + end end ), :".attributes.#{attr_name}", attr_name.humanize - ] + ].flatten ) defaults = [:"ransack.attributes.#{i18n_key(context.klass)}.#{name}"] if include_associations && associated_class