Class: Spree::Admin::Taxons::AttachmentController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/taxons/attachment_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/spree/admin/taxons/attachment_controller.rb', line 7

def destroy
  taxonomy = Spree::Taxonomy.find(params[:taxonomy_id])
  taxon = taxonomy.taxons.find(params[:taxon_id])
  if taxon.destroy_attachment(params[:attachment_definition])
    flash[:success] = t('spree.successfully_removed', resource: params[:attachment_definition].titleize)
  else
    flash[:error] = t('spree.taxon_attachment_removal_error')
  end
  redirect_to edit_admin_taxonomy_taxon_path(taxonomy, taxon.id)
end