Skip to content

Commit

Permalink
Merge branch 'patch-1' of https://github.com/Antronin/cancancan into …
Browse files Browse the repository at this point in the history
…Antronin-patch-1
  • Loading branch information
coorasse committed Nov 11, 2021
2 parents 8f93d81 + 8a12622 commit 08374ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/devise.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ end
It may be a good idea to specify the rescue from action:

```ruby
rescue_from CanCan::Unauthorized do |exception|
rescue_from CanCan::AccessDenied do |exception|
if current_user.nil?
session[:next] = request.fullpath
redirect_to login_url, alert: 'You have to log in to continue.'
else
# render file: "#{Rails.root}/public/403.html", status: 403
redirect_back(fallback_location: root_path)
respond_to do |format|
format.json { render nothing: true, status: :not_found }
format.html { redirect_to main_app.root_url, alert: exception.message }
format.js { render nothing: true, status: :not_found }
end
end
end
```

0 comments on commit 08374ff

Please sign in to comment.