Commit 46c690adc14ddc5b3f2d89ed9aec6706e46713ac
Committed by
Bob Lail
1 parent
6c95e407
Exists in
master
and in
1 other branch
rescue, globally, from RedirectBackError
Showing
1 changed file
with
18 additions
and
10 deletions
Show diff stats
app/controllers/application_controller.rb
1 | 1 | class ApplicationController < ActionController::Base |
2 | 2 | protect_from_forgery |
3 | - | |
3 | + | |
4 | 4 | before_filter :authenticate_user! |
5 | - | |
5 | + | |
6 | 6 | # Devise override - After login, if there is only one app, |
7 | 7 | # redirect to that app's path instead of the root path (apps#index). |
8 | 8 | def stored_location_for(resource) |
9 | 9 | location = super || root_path |
10 | 10 | (location == root_path && App.count == 1) ? app_path(App.first) : location |
11 | 11 | end |
12 | - | |
13 | - protected | |
14 | - | |
15 | - def require_admin! | |
16 | - redirect_to root_path unless user_signed_in? && current_user.admin? | |
17 | - end | |
18 | - | |
12 | + | |
13 | + rescue_from ActionController::RedirectBackError, :with => :redirect_to_root | |
14 | + | |
15 | + | |
16 | +protected | |
17 | + | |
18 | + | |
19 | + def require_admin! | |
20 | + redirect_to_root unless user_signed_in? && current_user.admin? | |
21 | + end | |
22 | + | |
23 | + def redirect_to_root | |
24 | + redirect_to(root_path) | |
25 | + end | |
26 | + | |
27 | + | |
19 | 28 | end |
20 | - | ... | ... |