Sha256: 20e50069f1d018bed6d6be443dedb1c8dc669b027c0ff5927fcee08af43e8f53
Contents?: true
Size: 773 Bytes
Versions: 12
Compression:
Stored size: 773 Bytes
Contents
module Locomotive module Concerns module ExceptionController extend ActiveSupport::Concern included do rescue_from Exception, with: :render_exception end private def render_exception(exception) ::Locomotive.log "[ApplicationError] #{exception.inspect}" status = (case exception when ::Mongoid::Errors::DocumentNotFound then 404 else raise exception unless request.xhr? 500 end) if request.xhr? render json: { error: exception.message }, status: status, layout: false else flash[:alert] = exception.message redirect_to current_site ? dashboard_path(current_site) : sites_path end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems