lib/ransack/helpers/form_builder.rb in ransack-1.8.8 vs lib/ransack/helpers/form_builder.rb in ransack-1.8.9

- old
+ new

@@ -4,18 +4,24 @@ # TODO: Find a better way to solve this issue! # This patch is needed since this Rails commit: # https://github.com/rails/rails/commit/c1a118a class Base private - if ::ActiveRecord::VERSION::STRING < '5.2' - def value(object) - object.send @method_name if object # use send instead of public_send + if defined? ::ActiveRecord + if ::ActiveRecord::VERSION::STRING < '5.2' + def value(object) + object.send @method_name if object # use send instead of public_send + end + else # rails/rails#29791 + def value + if @allow_method_names_outside_object + object.send @method_name if object && object.respond_to?(@method_name, true) + else + object.send @method_name if object + end + end end - else # rails/rails#29791 - def value - @object.send @method_name if @object - end - end + end end end RANSACK_FORM_BUILDER = 'RANSACK_FORM_BUILDER'.freeze