dimanche 1 août 2021

Ransack filtering on custom fields

I have a Data::Users with object types:

  id: "0e00392b-4205-43d1-8969-b6c7f2a92d8b",
  identifier: "bb7b38dc-bc21-4386-98a4-8d9738c11d5c",
  properties:
   {"name"=>"Vern Lueilwitz",
    "email"=>"carmen@altenwerth-batz.org",
    "last_time_entry_on"=>"2021-06-26",
    "liked_videos_count"=>201,
    "played_videos_count"=>609,
    "viewed_photos_count"=>143},
  created_at: Sat, 31 Jul 2021 17:24:48.836493000 UTC +00:00,
  updated_at: Sat, 31 Jul 2021 17:24:48.836493000 UTC +00:00,

When I try:

 Data::User.ransackable_attributes

I get the fields : ["id", "identifier", "created_at", "updated_at", "properties"]

The properties is a custom json which can contain any key and value. It is fetched from another server. I want to be able to ransack those custom fields. Any way I can extend ransack to allow filtering on those fields which are not on my table?

Aucun commentaire:

Enregistrer un commentaire