Handle errors using Gaffe
This commit is contained in:
parent
ae4979a3f0
commit
9efa9d5d43
12 changed files with 71 additions and 17 deletions
|
|
@ -160,6 +160,15 @@ table {
|
|||
}
|
||||
}
|
||||
|
||||
// Error page
|
||||
.large-error-icon {
|
||||
float: left;
|
||||
text-align: right;
|
||||
font-size: 160px;
|
||||
color: lightgrey;
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
// Tasks ..
|
||||
.accepted {
|
||||
color: #468847;
|
||||
|
|
|
|||
24
app/controllers/errors_controller.rb
Normal file
24
app/controllers/errors_controller.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
class ErrorsController < ApplicationController
|
||||
include Gaffe::Errors
|
||||
|
||||
skip_before_filter :authenticate
|
||||
|
||||
layout :current_layout
|
||||
|
||||
def show
|
||||
render "errors/#{@rescue_response}", status: @status_code
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_layout
|
||||
# Need foodcoop for `current_user`, even though it may not be retrieved from the url.
|
||||
params[:foodcoop] ||= session[:scope]
|
||||
current_user ? 'application' : 'login'
|
||||
end
|
||||
|
||||
def login_layout?
|
||||
current_user.nil?
|
||||
end
|
||||
helper_method :login_layout?
|
||||
end
|
||||
9
app/views/errors/_error.html.haml
Normal file
9
app/views/errors/_error.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
- title local_assigns[:title], false
|
||||
|
||||
- unless login_layout?
|
||||
%i.hidden-phone.large-error-icon.icon-exclamation-sign
|
||||
%div(class="#{login_layout? ? '' : 'span6'}")
|
||||
%h1= local_assigns[:title]
|
||||
%div(class='alert alert-#{local_assigns[:type] || 'warn'}')
|
||||
= local_assigns[:page]
|
||||
= link_to t('ui.back'), 'javascript:history.go(-1)', class: 'btn btn-primary'
|
||||
5
app/views/errors/internal_server_error.html.haml
Normal file
5
app/views/errors/internal_server_error.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
- page = capture do
|
||||
%p= t '.text1'
|
||||
%p= t '.text2'
|
||||
|
||||
= render 'error', title: t('.title'), type: :error, page: page
|
||||
4
app/views/errors/not_found.html.haml
Normal file
4
app/views/errors/not_found.html.haml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
- page = capture do
|
||||
%p= t '.text'
|
||||
|
||||
= render 'error', title: t('.title'), page: page
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
- title t('.title')
|
||||
= render :partial => 'form'
|
||||
= link_to t('.back'), finance_invoices_path
|
||||
= link_to t('ui.or_cancel'), finance_invoices_path
|
||||
|
|
|
|||
|
|
@ -36,5 +36,4 @@
|
|||
=h @invoice.note
|
||||
|
||||
= link_to t('ui.edit'), edit_finance_invoice_path(@invoice)
|
||||
|
|
||||
= link_to t('.back'), finance_invoices_path
|
||||
= link_to t('ui.or_cancel'), finance_invoices_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue