songtianlun
3203face6b
- 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.
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
ActiveAdmin.register City do
|
|
controller do
|
|
def find_resource
|
|
scoped_collection.friendly.find(params[:id])
|
|
end
|
|
end
|
|
|
|
# See permitted parameters documentation:
|
|
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
|
|
#
|
|
# Uncomment all parameters which should be permitted for assignment
|
|
#
|
|
permit_params :name, :country_id, :latitude, :longitude, :active, :priority, :timezone, :last_weather_fetch, :last_image_generation, :slug
|
|
#
|
|
# or
|
|
#
|
|
# permit_params do
|
|
# permitted = [:name, :country, :latitude, :longitude, :active, :priority, :timezone, :region, :last_weather_fetch, :last_image_generation, :slug]
|
|
# permitted << :other if params[:action] == 'create' && current_user.admin?
|
|
# permitted
|
|
# end
|
|
|
|
index do
|
|
selectable_column
|
|
id_column
|
|
column :name
|
|
column :country
|
|
column :region do |city|
|
|
city.region
|
|
end
|
|
column :latitude
|
|
column :longitude
|
|
column :active
|
|
actions
|
|
end
|
|
|
|
filter :name
|
|
filter :active
|
|
filter :country, as: :select
|
|
|
|
form do |f|
|
|
f.inputs do
|
|
f.input :active
|
|
f.input :name
|
|
f.input :country
|
|
f.input :latitude
|
|
f.input :longitude
|
|
f.input :priority
|
|
f.input :timezone
|
|
end
|
|
f.actions
|
|
end
|
|
end
|