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.
This commit is contained in:
songtianlun 2025-01-25 00:54:23 +08:00
parent 8364d42759
commit 3203face6b
2 changed files with 2 additions and 1 deletions

View File

@ -36,6 +36,7 @@ ActiveAdmin.register City do
filter :name
filter :active
filter :country, as: :select
form do |f|
f.inputs do

View File

@ -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