diff options
Diffstat (limited to 'help/app/controllers')
| -rw-r--r-- | help/app/controllers/tickets_controller.rb | 18 | 
1 files changed, 8 insertions, 10 deletions
| diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index b613088..d5a3da7 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -15,17 +15,15 @@ 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? -      flash[:notice] = flash[:notice] + ' You can later access this ticket at the url ' + request.protocol + request.host_with_port + ticket_path(@ticket.id) + '. You might want to bookmark this page to find it again. Anybody with this URL will be able to access this ticket, so if you are on a shared computer you might want to remove it from the browser history' #todo -    end + +    # cannot set this until ticket has been saved, as @ticket.id will not be set +    flash[:notice] += " " + t(:access_ticket_text, :full_url => ticket_url(@ticket.id)) if !logged_in? and flash[:notice]      respond_with(@ticket)    end | 
