Class: Spree::Relation

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/spree/relation.rb

Class Method Summary collapse

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object



20
21
22
# File 'app/models/spree/relation.rb', line 20

def self.ransackable_associations(_auth_object = nil)
  %w[relation_type relatable related_to]
end

.ransackable_attributes(_auth_object = nil) ⇒ Object

Spree 5.2(Ransack 4.x)は検索・ソート対象を明示的に allowlist することを要求する。 ApplicationRecord 継承で Spree::Core::Ransackable を含まないため、Ransack 標準の ransackable_attributes / ransackable_associations をオーバーライドして許可する。



16
17
18
# File 'app/models/spree/relation.rb', line 16

def self.ransackable_attributes(_auth_object = nil)
  %w[id relation_type_id relatable_type relatable_id related_to_type related_to_id discount_amount position created_at updated_at]
end