Skip to content

Commit b0ec01e

Browse files
authored
Fix lingering flash messages (#4932)
1 parent cf5c061 commit b0ec01e

27 files changed

+47
-47
lines changed

app/controllers/account_requests_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create
2525
@bank_selected = true
2626

2727
if !verify_recaptcha(model: @account_request)
28-
flash[:alert] = "Invalid captcha submission"
28+
flash.now[:alert] = "Invalid captcha submission"
2929
render :new
3030
elsif @account_request.save
3131
AccountRequestMailer.confirmation(account_request_id: @account_request.id).deliver_later

app/controllers/adjustments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def create
4545
flash[:notice] = "Adjustment was successful."
4646
redirect_to adjustment_path(@adjustment)
4747
else
48-
flash[:error] = @adjustment.errors.collect { |error| "#{error.attribute}: " + error.message }.join("<br />".html_safe)
48+
flash.now[:error] = @adjustment.errors.collect { |error| "#{error.attribute}: " + error.message }.join("<br />".html_safe)
4949
load_form_collections
5050
render :new
5151
end

app/controllers/admin/barcode_items_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def update
1010
if @barcode_item.update(barcode_item_params)
1111
redirect_to admin_barcode_items_path, notice: "Updated Barcode Item!"
1212
else
13-
flash[:error] = "Failed to update this Barcode Item."
13+
flash.now[:error] = "Failed to update this Barcode Item."
1414
render :edit
1515
end
1616
end
@@ -33,7 +33,7 @@ def create
3333
end
3434
else
3535
load_base_items
36-
flash[:error] = "Failed to create Barcode Item."
36+
flash.now[:error] = "Failed to create Barcode Item."
3737
render :new
3838
end
3939
end

app/controllers/admin/base_items_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def update
1212
if @base_item.update(base_item_params)
1313
redirect_to admin_base_items_path, notice: "Updated base item!"
1414
else
15-
flash[:error] = "Failed to update this base item."
15+
flash.now[:error] = "Failed to update this base item."
1616
render :edit
1717
end
1818
end
@@ -30,7 +30,7 @@ def create
3030
if @base_item.save
3131
redirect_to admin_base_items_path, notice: "Base Item added!"
3232
else
33-
flash[:error] = "Failed to create Base Item."
33+
flash.now[:error] = "Failed to create Base Item."
3434
render :new
3535
end
3636
end

app/controllers/admin/organizations_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def update
1010
if OrganizationUpdateService.update(@organization, organization_params)
1111
redirect_to admin_organizations_path, notice: "Updated organization!"
1212
else
13-
flash[:error] = @organization.errors.full_messages.join("\n")
13+
flash.now[:error] = @organization.errors.full_messages.join("\n")
1414
render :edit
1515
end
1616
end
@@ -57,11 +57,11 @@ def create
5757
SnapshotEvent.publish(@organization) # need one to start with
5858
redirect_to admin_organizations_path, notice: "Organization added!"
5959
else
60-
flash[:error] = "Failed to create Organization."
60+
flash.now[:error] = "Failed to create Organization."
6161
render :new
6262
end
6363
rescue => e
64-
flash[:error] = e
64+
flash.now[:error] = e
6565
render :new
6666
end
6767

app/controllers/admin/partners_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def update
1616
if @partner.update(partner_attributes)
1717
redirect_to admin_partners_path, notice: "#{@partner.name} updated!"
1818
else
19-
flash[:error] = "Something didn't work quite right -- try again?"
19+
flash.now[:error] = "Something didn't work quite right -- try again?"
2020
render action: :edit
2121
end
2222
end

app/controllers/admin/questions_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def create
1212
if @question.save
1313
redirect_to admin_questions_path
1414
else
15-
flash[:error] = "Failed to create question. #{@question.punctuate(@question.errors.to_a)}"
15+
flash.now[:error] = "Failed to create question. #{@question.punctuate(@question.errors.to_a)}"
1616
render :new
1717
end
1818
end
@@ -26,7 +26,7 @@ def update
2626
if @question.update(question_params)
2727
redirect_to admin_questions_path
2828
else
29-
flash[:error] = "Failed to update question. #{@question.punctuate(@question.errors.to_a)}"
29+
flash.now[:error] = "Failed to update question. #{@question.punctuate(@question.errors.to_a)}"
3030
render :edit
3131
end
3232
end

app/controllers/admin/users_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create
4646
flash[:notice] = "Created a new user!"
4747
redirect_to admin_users_path
4848
rescue => e
49-
flash[:error] = "Failed to create user: #{e}"
49+
flash.now[:error] = "Failed to create user: #{e}"
5050
render :new
5151
end
5252

app/controllers/audits_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def update
3636
if @audit.update(audit_params)
3737
save_audit_status_and_redirect(params)
3838
else
39-
flash[:error] = @audit.errors.full_messages.join("\n")
39+
flash.now[:error] = @audit.errors.full_messages.join("\n")
4040
@storage_locations = [@audit.storage_location]
4141
set_items
4242
@audit.line_items.build if @audit.line_items.empty?
@@ -64,7 +64,7 @@ def create
6464
render :new
6565
end
6666
rescue Errors::InsufficientAllotment, InventoryError => e
67-
flash[:error] = e.message
67+
flash.now[:error] = e.message
6868
render :new
6969
end
7070

@@ -81,7 +81,7 @@ def handle_audit_errors
8181
attr = (error.attribute.to_s == 'base') ? '' : error.attribute.capitalize
8282
"#{attr} ".tr("_", " ") + error.message
8383
end
84-
flash[:error] = error_message.join(", ")
84+
flash.now[:error] = error_message.join(", ")
8585
end
8686

8787
def set_audit

app/controllers/barcode_items_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def create
2727
format.html { redirect_to barcode_items_path, notice: msg }
2828
end
2929
else
30-
flash[:error] = "Something didn't work quite right -- try again?"
30+
flash.now[:error] = "Something didn't work quite right -- try again?"
3131
render action: :new
3232
end
3333
end
@@ -78,7 +78,7 @@ def update
7878
if @barcode_item.update(barcode_item_params)
7979
redirect_to barcode_items_path, notice: "Barcode updated!"
8080
else
81-
flash[:error] = "Something didn't work quite right -- try again?"
81+
flash.now[:error] = "Something didn't work quite right -- try again?"
8282
render action: :edit
8383
end
8484
end

0 commit comments

Comments
 (0)