diff --git a/lib/ransack/nodes/bindable.rb b/lib/ransack/nodes/bindable.rb index ed18e65..b80d8ae 100644 --- a/lib/ransack/nodes/bindable.rb +++ b/lib/ransack/nodes/bindable.rb @@ -5,9 +5,7 @@ module Ransack attr_accessor :parent, :attr_name def attr - @attr ||= ransacker ? - ransacker.attr_from(self) : - context.table_for(parent)[attr_name] + @attr ||= get_arel_attribute end alias :arel_attribute :attr @@ -27,6 +25,16 @@ module Ransack @parent = @attr_name = @attr = @klass = nil end + private + + def get_arel_attribute + if ransacker + ransacker.attr_from(self) + else + context.table_for(parent)[attr_name] + end + end + end end -end \ No newline at end of file +end