summaryrefslogtreecommitdiff
path: root/engines/support/app
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-20 13:09:59 +0200
committerAzul <azul@leap.se>2014-05-26 12:59:26 +0200
commitc10f9311678ff2183443bc03e153b30d3b68ff74 (patch)
treea81a236e2e7d0429d45c24efa5592a7233a63ab3 /engines/support/app
parent467dd712a19d48fc653cfc0e58201e6657d2c1f9 (diff)
Controller#flash_for instead of FlashResponder
FlashResponder added a flash before responding. However at the point of responding objects have already been saved. So there is no way to test if they were changed. Now instead we can call flash_for resource before resource.save and it will add the flash messages only if the resource was actually changed.
Diffstat (limited to 'engines/support/app')
-rw-r--r--engines/support/app/controllers/tickets_controller.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb
index bb98277..7b6a7a0 100644
--- a/engines/support/app/controllers/tickets_controller.rb
+++ b/engines/support/app/controllers/tickets_controller.rb
@@ -23,10 +23,11 @@ class TicketsController < ApplicationController
@ticket.comments.last.posted_by = current_user.id
@ticket.comments.last.private = false unless admin?
@ticket.created_by = current_user.id
+ flash_for @ticket
if @ticket.save && !logged_in?
flash[:success] = t(:access_ticket_text, :full_url => ticket_url(@ticket.id))
end
- respond_with(@ticket, :location => auto_ticket_path(@ticket))
+ respond_with @ticket, :location => auto_ticket_path(@ticket)
end
def show
@@ -61,6 +62,7 @@ class TicketsController < ApplicationController
@ticket.comments.last.private = false unless admin?
end
+ flash_for @ticket
@ticket.save
respond_with @ticket, location: redirection_path
end
@@ -82,10 +84,6 @@ class TicketsController < ApplicationController
@title = t(:tickets)
end
- def self.responder
- Responders::FlashResponder
- end
-
private
#