Skip to content

Commit

Permalink
Merge pull request #14 from fschwahn/master
Browse files Browse the repository at this point in the history
explicitly state the format of the template
  • Loading branch information
logankoester committed Feb 7, 2013
2 parents 074867d + 66e7526 commit 4b417c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source "http://rubygems.org"
group :development do
gem 'rake', '>= 0'
gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "bundler", "~> 1.0"
gem "jeweler", "~> 1.6.0"
gem "rcov", ">= 0"
end
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
en:
errship:
standard: 'An unknown error has occurred, or you have reached this page by mistake.'
'404':
title: 'This page does not exist.'
description: 'It could have moved, or someone (maybe you!) mistyped the URL.'
Expand Down
20 changes: 13 additions & 7 deletions lib/errship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ def self.included(base)

def render_error(exception, errship_scope = false)
airbrake_class.send(:notify, exception) if airbrake_class
render :template => '/errship/standard', :locals => {
:status_code => 500, :errship_scope => errship_scope }, :status => (Errship.status_code_success ? 200 : 500)
render :template => '/errship/standard.html.erb',
:layout => 'application',
:locals => { :status_code => 500, :errship_scope => errship_scope },
:status => (Errship.status_code_success ? 200 : 500)
end

def render_404_error(exception = nil, errship_scope = false)
render :template => '/errship/standard', :locals => {
:status_code => 404, :errship_scope => errship_scope }, :status => (Errship.status_code_success ? 200 : 404)
render :template => '/errship/standard.html.erb',
:layout => 'application',
:locals => { :status_code => 404, :errship_scope => errship_scope },
:status => (Errship.status_code_success ? 200 : 404)
end

# A blank page with just the layout and flash message, which can be redirected to when
# all else fails.
def errship_standard(errship_scope = false)
flash[:error] ||= 'An unknown error has occurred, or you have reached this page by mistake.'
render :template => '/errship/standard', :locals => {
:status_code => 500, :errship_scope => errship_scope }
flash[:error] ||= I18n.t('errship.standard')
render :template => '/errship/standard.html.erb',
:layout => 'application',
:locals => { :status_code => 500, :errship_scope => errship_scope },
:status => (Errship.status_code_success ? 200 : 500)
end

# Set the error flash and attempt to redirect back. If RedirectBackError is raised,
Expand Down

0 comments on commit 4b417c5

Please sign in to comment.