From 2379cc0c3c28d579041aefebb10ee6a753b00519 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Mon, 12 Aug 2013 15:03:09 +1000 Subject: [PATCH] Do not display double error when using js --- app/controllers/admin/enterprise_fees_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/enterprise_fees_controller.rb b/app/controllers/admin/enterprise_fees_controller.rb index 41450c82c9..2aa2a3aa30 100644 --- a/app/controllers/admin/enterprise_fees_controller.rb +++ b/app/controllers/admin/enterprise_fees_controller.rb @@ -28,11 +28,14 @@ module Admin product_distribution = ProductDistribution.where(:enterprise_fee_id => @object).first if product_distribution p = product_distribution.product - flash[:error] = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}." + error = "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}." respond_with(@object) do |format| - format.html { redirect_to collection_url } - format.js { render text: flash[:error], status: 403 } + format.html do + flash[:error] = error + redirect_to collection_url + end + format.js { render text: error, status: 403 } end end end