-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from foodcoops/feature/370-error-handling
Render error pages with application layout
- Loading branch information
Showing
12 changed files
with
71 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- page = capture do | ||
%p= t '.text1' | ||
%p= t '.text2' | ||
|
||
= render 'error', title: t('.title'), type: :error, page: page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- page = capture do | ||
%p= t '.text' | ||
|
||
= render 'error', title: t('.title'), page: page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if Rails.env.production? || Rails.env.staging? || true | ||
Gaffe.configure do |config| | ||
config.errors_controller = 'ErrorsController' | ||
end | ||
Gaffe.enable! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.