Skip to content

Commit e9dc2e4

Browse files
committed
Do not filter out scopes from Ransack queries
Scopes are special in that they don't have a predicate. This removes the check for the predicate, and thus makes scopes as filtering options work with JSONAPI.rb.
1 parent f8f8e7e commit e9dc2e4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/jsonapi/filtering.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def jsonapi_filter_params(allowed_fields)
6262
to_filter = to_filter.split(',')
6363
end
6464

65-
if predicates.any? && (field_names - allowed_fields).empty?
65+
if (field_names - allowed_fields).empty?
6666
filtered[requested_field] = to_filter
6767
end
6868
end

spec/dummy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
class User < ActiveRecord::Base
3333
has_many :notes
3434

35-
scope :created_before, ->(date) { where("created_at < ?", date) }
35+
scope :created_before, ->(date) { where('created_at < ?', date) }
3636

3737
def self.ransackable_scopes(_auth_object = nil)
3838
[:created_before]

0 commit comments

Comments
 (0)