jeudi 16 février 2023

Rails admin gem, polymorphic association

How to get the queried data having polymorphic association

I have an 3 models

class Picture < ApplicationRecord
  belongs_to :imageable, polymorphic: true
end

class Employee < ApplicationRecord
  has_many :pictures, as: :imageable
end

class Product < ApplicationRecord
  has_many :pictures, as: :imageable
end```

Employee and Product have column **is_active**.
In rails admin dropdown. I want to display the data where employee and product is **is_active = true.**

Have tried multiple ways to achieve this.
Please let me know if there is any solution?

Aucun commentaire:

Enregistrer un commentaire