songtianlun
8364d42759
- Added country input field to the city form for better user experience. - Removed unused region and weather-related fields to declutter the form. This change improves the data captured for cities and enhances the form's usability by focusing on relevant information.
53 lines
1.3 KiB
Ruby
53 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
|
|
|
|
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
|