Handle errors using Gaffe
This commit is contained in:
parent
ae4979a3f0
commit
9efa9d5d43
12 changed files with 71 additions and 17 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue