From 3203face6b0b79f8435af178ae279b7550b10a6b Mon Sep 17 00:00:00 2001 From: songtianlun Date: Sat, 25 Jan 2025 00:54:23 +0800 Subject: [PATCH] feat: add country filter in city admin - Introduce a new filter for selecting cities by country in the ActiveAdmin interface. - Update the ransackable attributes to include country_id for searchable functionality. This change enhances the Admin UI by allowing easier access to city data based on country, improving the user experience for administrators. --- app/admin/cities.rb | 1 + app/models/city.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/admin/cities.rb b/app/admin/cities.rb index 3cdad36..013b901 100644 --- a/app/admin/cities.rb +++ b/app/admin/cities.rb @@ -36,6 +36,7 @@ ActiveAdmin.register City do filter :name filter :active + filter :country, as: :select form do |f| f.inputs do diff --git a/app/models/city.rb b/app/models/city.rb index aa1d920..9be6e39 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -45,7 +45,7 @@ class City < ApplicationRecord end def self.ransackable_attributes(auth_object = nil) - [ "active", "country", "created_at", "id", "id_value", "last_image_generation", "last_weather_fetch", "latitude", "longitude", "name", "priority", "region", "slug", "timezone", "updated_at" ] + [ "active", "country_id", "created_at", "id", "id_value", "last_image_generation", "last_weather_fetch", "latitude", "longitude", "name", "priority", "region", "slug", "timezone", "updated_at" ] end def last_weather_fetch