app/controllers/spree/admin/taxons_controller.rb in solidus_backend-2.10.5 vs app/controllers/spree/admin/taxons_controller.rb in solidus_backend-2.11.0
- old
+ new
@@ -1,10 +1,11 @@
# frozen_string_literal: true
module Spree
module Admin
class TaxonsController < Spree::Admin::BaseController
+ rescue_from ActiveRecord::RecordNotFound, with: :resource_not_found
respond_to :html, :json, :js
def index
end
@@ -60,11 +61,17 @@
if @taxon.save
flash[:success] = flash_message_for(@taxon, :successfully_updated)
end
respond_with(@taxon) do |format|
- format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
+ format.html do
+ if @taxon.valid?
+ redirect_to edit_admin_taxonomy_url(@taxonomy)
+ else
+ render :edit
+ end
+ end
end
end
def destroy
@taxon = Spree::Taxon.find(params[:id])
@@ -74,9 +81,13 @@
private
def taxon_params
params.require(:taxon).permit(permitted_taxon_attributes)
+ end
+
+ def resource_not_found
+ super(flash_class: Taxon, redirect_url: admin_taxonomies_path)
end
end
end
end