From 92e330abc8655628b69a34d40c8d25a4f29d16fd Mon Sep 17 00:00:00 2001 From: abMatGit Date: Mon, 8 Jan 2024 17:11:18 -0800 Subject: [PATCH] Issue #1472 suggested fix --- .ruby-version | 1 + lib/ransack/search.rb | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..0aec50e6 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.1.4 diff --git a/lib/ransack/search.rb b/lib/ransack/search.rb index a8bf95f8..3d7b8a51 100644 --- a/lib/ransack/search.rb +++ b/lib/ransack/search.rb @@ -102,14 +102,14 @@ def new_sort(opts = {}) def method_missing(method_id, *args) method_name = method_id.to_s getter_name = method_name.sub(/=$/, ''.freeze) - if base.attribute_method?(getter_name) - base.send(method_id, *args) - elsif @context.ransackable_scope?(getter_name, @context.object) + if @context.ransackable_scope?(getter_name, @context.object) if method_name =~ /=$/ add_scope getter_name, args else @scope_args[method_name] end + elsif base.attribute_method?(getter_name) + base.send(method_id, *args) else super end