Skip to content

Commit

Permalink
Fix issue in README for multiple error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
holyketzer committed Jan 17, 2020
1 parent 6be4621 commit 80295d4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,14 @@ end
Then you can get this error message in exception handler:
```ruby
rescue_from Pundit::NotAuthorizedError do |e|
message = e.reason ? I18n.t("pundit.errors.#{e.reason}") : e.message
flash[:error] = message, scope: "pundit", default: :default
message =
if e.reason
I18n.t("pundit.errors.#{e.reason}", scope: "pundit", default: :default)
else
e.message
end
flash[:error] = message
redirect_to(request.referrer || root_path)
end
```
Expand Down

0 comments on commit 80295d4

Please sign in to comment.