-
-
Notifications
You must be signed in to change notification settings - Fork 829
Milestone
Description
Ruby: 3.1.3
Rails: 7.0.4
Ransack: 3.2.1
Basic Setup
# -- Intervention Model --
class Intervention < ApplicationRecord
belongs_to :father, class_name: "Intervention", foreign_key: "intervention_id", optional: true
has_one :child, class_name: "Intervention", foreign_key: "intervention_id", dependent: :destroy
scope :neither_father_nor_child, -> { where.missing(:father, :child) }
def self.ransackable_scopes(auth_object = nil)
%i[neither_father_nor_child]
end
end
h = {:g=>{"0"=>{:neither_father_nor_child=>1}}}
Intervention.ransack(h) # => Ransack::Search<class: Intervention, base: Grouping <combinator: and>>
Intervention.ransack(h).result.to_sql # => SELECT \"interventions\".* FROM \"interventions\"
It is not calling the defined scope, but if i try
Intervention.ransack(neither_father_nor_child: 1) => # Ransack::Search<class: Intervention, scope: {"neither_father_nor_child"=>1}, base: Grouping <combinator: and>
So I don't know where is the problem