summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2013-01-22 11:17:10 -0800
committerjessib <jessib@leap.se>2013-01-22 11:17:10 -0800
commitdea7680b7260224beb2d2b8b901310f27d7337b0 (patch)
treed489c9dae137996163f560f2ac8209dbe7ce2d91
parente1c0b7f23d7be1d8f3139aa255bd121969ece97a (diff)
Makes tickets_controller a bit less complex.
-rw-r--r--help/app/controllers/tickets_controller.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb
index 372ff6e..3ccebb3 100644
--- a/help/app/controllers/tickets_controller.rb
+++ b/help/app/controllers/tickets_controller.rb
@@ -15,13 +15,11 @@ class TicketsController < ApplicationController
def create
@ticket = Ticket.new(params[:ticket])
- if logged_in?
- @ticket.created_by = current_user.id
- @ticket.email = current_user.email if current_user.email
- @ticket.comments.last.posted_by = current_user.id
- else
- @ticket.comments.last.posted_by = nil #hacky, but protecting this attribute doesn't work right, so this should make sure it isn't set.
- end
+
+ @ticket.comments.last.posted_by = (logged_in? ? current_user.id : nil) #protecting posted_by isn't working, so this should protect it.
+ @ticket.created_by = current_user.id if logged_in?
+ @ticket.email = current_user.email if logged_in? and current_user.email
+
flash[:notice] = 'Ticket was successfully created.' if @ticket.save
if !logged_in?
# cannot set this until ticket has been saved, as @ticket.id will not be set