summaryrefslogtreecommitdiff
path: root/engines/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-04-22 14:39:43 +0200
committerAzul <azul@leap.se>2014-04-24 20:36:11 +0200
commitc275f43147e7a8ab54623bdc5b9a8124b8592330 (patch)
treebf24395fa5c98d1fef89eda981391417d804c170 /engines/support
parent79b14e638d14b02d9747f42984433fd7d77b0ea8 (diff)
return nil as auto_ticket_path for invalid tickets
The auto_ticket_path is referenced from the tickets_controller like this: respond_with(@ticket, :location => auto_ticket_path(@ticket)) While this only uses the location parameter when the ticket is valid it will still attampt to calculate it if not. During the create action this will lead to crashes because the ticket_path can not be calculated for a ticket without an id. This led to https://leap.se/code/issues/5552 and probably https://leap.se/code/issues/5545.
Diffstat (limited to 'engines/support')
-rw-r--r--engines/support/app/helpers/auto_tickets_path_helper.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/engines/support/app/helpers/auto_tickets_path_helper.rb b/engines/support/app/helpers/auto_tickets_path_helper.rb
index 93f3cb9..5638222 100644
--- a/engines/support/app/helpers/auto_tickets_path_helper.rb
+++ b/engines/support/app/helpers/auto_tickets_path_helper.rb
@@ -23,6 +23,7 @@ module AutoTicketsPathHelper
end
def auto_ticket_path(ticket, options={})
+ return unless ticket.persisted?
options = ticket_view_options.merge options
if @user
user_ticket_path(@user, ticket, options)
@@ -50,4 +51,4 @@ module AutoTicketsPathHelper
hsh
end
-end \ No newline at end of file
+end