2025-01-21 18:27:26 +08:00
|
|
|
ActiveAdmin.register Country do
|
2025-01-28 01:03:06 +08:00
|
|
|
menu label: "Country Manager", parent: "系统管理"
|
2025-01-25 01:29:50 +08:00
|
|
|
controller do
|
|
|
|
def find_resource
|
|
|
|
scoped_collection.friendly.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|
2025-01-21 18:27:26 +08:00
|
|
|
# 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, :code, :region_id
|
|
|
|
#
|
|
|
|
# or
|
|
|
|
#
|
|
|
|
# permit_params do
|
|
|
|
# permitted = [:name, :code, :slug, :region_id]
|
|
|
|
# permitted << :other if params[:action] == 'create' && current_user.admin?
|
|
|
|
# permitted
|
|
|
|
# end
|
|
|
|
index do
|
|
|
|
selectable_column
|
|
|
|
id_column
|
|
|
|
column :name
|
|
|
|
column :code
|
|
|
|
column :region
|
|
|
|
column :cities_count do |country|
|
|
|
|
country.cities.count
|
|
|
|
end
|
|
|
|
actions
|
|
|
|
end
|
|
|
|
|
|
|
|
form do |f|
|
|
|
|
f.inputs do
|
|
|
|
f.input :region
|
|
|
|
f.input :name
|
|
|
|
f.input :code
|
|
|
|
end
|
|
|
|
f.actions
|
|
|
|
end
|
|
|
|
end
|