Module: ControllerMixins::Tickets

Included in:
ClientLogin::TicketsController, TicketsController
Defined in:
lib/controller_mixins/tickets.rb

Instance Method Summary collapse

Instance Method Details

#create!(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/controller_mixins/tickets.rb', line 3

def create!(path)
  if @ticket.save
    if request.xhr?
      flash.now[:notice] = t(:ticket_created_successfully)
      render :json => "{\"success\": true}", :layout => false, :status => 200 and return
    else
      flash[:notice] = t(:ticket_created_successfully)
    end
    redirect_to send(path, @ticket) and return
  else
    if request.xhr?
      render :json => @ticket.errors.full_messages.to_json, :layout => false, :status => 406 and return
    end
    flash[:error] = t(:ticket_created_unsuccessfully)
    render :action => :new and return
  end
end