From 730e31017109994c24db431fde12f575ed5c1467 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 20 May 2014 09:13:25 +0200 Subject: FlashResponder will automagically add flash messages --- engines/support/app/controllers/tickets_controller.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/support/app/controllers/tickets_controller.rb b/engines/support/app/controllers/tickets_controller.rb index 99357ab..19663c3 100644 --- a/engines/support/app/controllers/tickets_controller.rb +++ b/engines/support/app/controllers/tickets_controller.rb @@ -23,11 +23,8 @@ class TicketsController < ApplicationController @ticket.comments.last.posted_by = current_user.id @ticket.comments.last.private = false unless admin? @ticket.created_by = current_user.id - if @ticket.save - flash[:notice] = t(:thing_was_successfully_created, :thing => t(:ticket)) - if !logged_in? - flash[:notice] += " " + t(:access_ticket_text, :full_url => ticket_url(@ticket.id)) - end + 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)) end @@ -62,10 +59,8 @@ class TicketsController < ApplicationController end if @ticket.changed? and @ticket.save - flash[:notice] = t(:changes_saved) redirect_to_tickets else - flash[:error] = @ticket.errors.full_messages.join(". ") if @ticket.changed? redirect_to auto_ticket_path(@ticket) end end @@ -88,6 +83,10 @@ class TicketsController < ApplicationController @title = t(:tickets) end + def self.responder + Responders::FlashResponder + end + private # -- cgit v1.2.3