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, :latitude, :longitude, :active, :priority, :timezone, :region, :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 :slug
    column :latitude
    column :longitude
    column :active
    column :created_at
    actions
  end

  filter :name
  filter :active

  form do |f|
    f.inputs do
      f.input :active
      f.input :name
      f.input :country, as: :String
      f.input :latitude
      f.input :longitude
      f.input :priority
      f.input :timezone
      f.input :region
      f.input :last_weather_fetch
      f.input :last_image_generation
    end
    f.actions
  end
  
end
