<commit_before># frozen_string_literal: true
ActiveAdmin.register Audio do
  menu parent: I18n.t('admin_menu.assets')

  permit_params :id,
                :online,
                :audio

  # decorate_with PictureDecorator
  config.clear_sidebar_sections!
  actions :all, except: [:new]

  batch_action :toggle_online do |ids|
    Audio.find(ids).each { |item| item.toggle! :online }
    redirect_to :back, notice: t('active_admin.batch_actions.flash')
  end

  index do
    selectable_column
    attachment_column(t('activerecord.attributes.audio.audio'), :audio, truncate: false)
    bool_column :online
    actions
  end

  show do
    arbre_cache(self, resource.cache_key) do
      attributes_table do
        attachment_row(t('activerecord.attributes.audio.audio'), :audio, truncate: false)
        bool_row :online
      end
    end
  end

  form do |f|
    f.semantic_errors(*f.object.errors.keys)

    columns do
      column do
        f.inputs t('active_admin.details', model: active_admin_config.resource_label) do
          f.input :audio,
                  as: :file,
                  hint: I18n.t('form.hint.audio.audio_file')
          f.input :online,
                  label: I18n.t('form.label.online'),
                  hint: I18n.t('form.hint.online')
        end
      end
    end

    f.actions
  end

  #
  # == Controller
  #
  controller do
    include Skippable

    def destroy
      resource.audio.clear
      resource.save
      super
    end
  end
end
<commit_msg>Specify to use AudioDecorator in AA Audio resource (still commented for now)<commit_after># frozen_string_literal: true
ActiveAdmin.register Audio do
  menu parent: I18n.t('admin_menu.assets')

  permit_params :id,
                :online,
                :audio

  # decorate_with AudioDecorator
  config.clear_sidebar_sections!
  actions :all, except: [:new]

  batch_action :toggle_online do |ids|
    Audio.find(ids).each { |item| item.toggle! :online }
    redirect_to :back, notice: t('active_admin.batch_actions.flash')
  end

  index do
    selectable_column
    attachment_column(t('activerecord.attributes.audio.audio'), :audio, truncate: false)
    bool_column :online
    actions
  end

  show do
    arbre_cache(self, resource.cache_key) do
      attributes_table do
        attachment_row(t('activerecord.attributes.audio.audio'), :audio, truncate: false)
        bool_row :online
      end
    end
  end

  form do |f|
    f.semantic_errors(*f.object.errors.keys)

    columns do
      column do
        f.inputs t('active_admin.details', model: active_admin_config.resource_label) do
          f.input :audio,
                  as: :file,
                  hint: I18n.t('form.hint.audio.audio_file')
          f.input :online,
                  label: I18n.t('form.label.online'),
                  hint: I18n.t('form.hint.online')
        end
      end
    end

    f.actions
  end

  #
  # == Controller
  #
  controller do
    include Skippable

    def destroy
      resource.audio.clear
      resource.save
      super
    end
  end
end

{'fraction_non_alphanumeric': 0.09492635024549918, 'fraction_numerical': 0.005237315875613748, 'mean_word_length': 2.3289760348583877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2481949', 'n_tokens_mistral': 991, 'n_tokens_neox': 942, 'n_words': 217}