Class: Softwear::ErrorReportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/softwear/error_reports_controller.rb

Instance Method Summary collapse

Instance Method Details

#email_reportObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/softwear/error_reports_controller.rb', line 15

def email_report
  if current_user
    user = current_user
  else
    begin
      user = User.find(params[:user_id]) unless params[:user_id].blank?
    rescue StandardError => _e
    end
  end

  ErrorReportMailer.send_report(user, params).deliver
  flash[:success] = 'Sent error report. Sorry about that and thank you for your submission.'

  if user
    redirect_to '/'
  elsif params[:order_id] && (key = Order.where(id: params[:order_id]).pluck(:customer_key).first)
    redirect_to customer_order_path(key)
  else
    render inline: "<%= flash[:success] %>"
  end
end