2025-01-19 12:21:00 +08:00
|
|
|
ActiveAdmin.register WeatherArt do
|
2025-01-22 14:04:58 +08:00
|
|
|
controller do
|
|
|
|
def find_resource
|
|
|
|
scoped_collection.friendly.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|
2025-01-19 12:21:00 +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 :city_id, :weather_date, :description, :temperature, :feeling_temp, :humidity, :wind_scale, :wind_speed, :precipitation, :pressure, :visibility, :cloud, :prompt
|
|
|
|
#
|
|
|
|
# or
|
|
|
|
#
|
|
|
|
# permit_params do
|
|
|
|
# permitted = [:city_id, :weather_date, :description, :temperature, :feeling_temp, :humidity, :wind_scale, :wind_speed, :precipitation, :pressure, :visibility, :cloud, :prompt]
|
|
|
|
# permitted << :other if params[:action] == 'create' && current_user.admin?
|
|
|
|
# permitted
|
|
|
|
# end
|
|
|
|
permit_params :city_id, :weather_date, :description, :temperature,
|
|
|
|
:feeling_temp, :humidity, :wind_scale, :wind_speed,
|
|
|
|
:precipitation, :pressure, :visibility, :cloud,
|
2025-01-22 16:50:00 +08:00
|
|
|
:prompt, :image, :slug
|
2025-01-19 12:21:00 +08:00
|
|
|
|
|
|
|
remove_filter :image_attachment, :image_blob
|
2025-01-22 16:50:00 +08:00
|
|
|
filter :city_id
|
|
|
|
filter :weather_data
|
2025-01-19 12:21:00 +08:00
|
|
|
|
|
|
|
index do
|
|
|
|
selectable_column
|
|
|
|
id_column
|
|
|
|
column :city
|
|
|
|
column :weather_date
|
|
|
|
column :description
|
|
|
|
column :temperature
|
|
|
|
column :image do |weather_art|
|
2025-01-20 18:08:55 +08:00
|
|
|
image_tag(weather_art.image, size: "100x100") if weather_art.image.attached?
|
2025-01-19 12:21:00 +08:00
|
|
|
end
|
|
|
|
actions
|
|
|
|
end
|
|
|
|
|
|
|
|
show do
|
|
|
|
attributes_table do
|
|
|
|
row :city
|
|
|
|
row :weather_date
|
|
|
|
row :description
|
|
|
|
row :temperature
|
|
|
|
row :feeling_temp
|
|
|
|
row :humidity
|
|
|
|
row :wind_scale
|
|
|
|
row :wind_speed
|
|
|
|
row :precipitation
|
|
|
|
row :pressure
|
|
|
|
row :visibility
|
|
|
|
row :cloud
|
|
|
|
row :prompt
|
|
|
|
row :image do |weather_art|
|
|
|
|
image_tag(weather_art.image) if weather_art.image.attached?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
form do |f|
|
|
|
|
f.inputs do
|
|
|
|
f.input :city
|
|
|
|
f.input :weather_date
|
|
|
|
f.input :description
|
|
|
|
f.input :temperature
|
|
|
|
f.input :feeling_temp
|
|
|
|
f.input :humidity
|
|
|
|
f.input :wind_scale
|
|
|
|
f.input :wind_speed
|
|
|
|
f.input :precipitation
|
|
|
|
f.input :pressure
|
|
|
|
f.input :visibility
|
|
|
|
f.input :cloud
|
|
|
|
f.input :prompt
|
|
|
|
f.input :image, as: :file
|
|
|
|
end
|
|
|
|
f.actions
|
|
|
|
end
|
|
|
|
end
|