Sha256: a204945d15189ea62cdfe75c732dade42400023772b0704be2ddf236774a9c26

Contents?: true

Size: 1.2 KB

Versions: 18

Compression:

Stored size: 1.2 KB

Contents

module Softwear
  class ErrorReportsController < ApplicationController
    skip_before_filter :authenticate_user!
    before_action :assign_current_user, only: :email_report

    helper Softwear::Engine.helpers do
      def method_missing(name, *args, &block)
        if main_app.respond_to?(name)   
          main_app.send(name, *args, &block)
        else                   
          super                
        end                    
      end
    end

    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_now
      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

    private
    
    def assign_current_user
      @current_user = current_user rescue nil 
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
softwear-lib-3.1.1 app/controllers/softwear/error_reports_controller.rb
softwear-lib-3.1.0 app/controllers/softwear/error_reports_controller.rb
softwear-lib-3.0.0 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.7 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.6 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.4 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.3 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.2 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.1 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.1.0 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.13 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.12 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.11 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.10 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.9.2 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.9.1 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.9 app/controllers/softwear/error_reports_controller.rb
softwear-lib-2.0.8 app/controllers/softwear/error_reports_controller.rb