varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.24k stars 627 forks source link

Update an error message code example in the README #669

Closed astronaut-wannabe closed 3 years ago

astronaut-wannabe commented 3 years ago

the issue

I believe the existing example here has some copypasta from the previous example: https://github.com/varvet/pundit/blob/a09548c826b85ced18a2e54ec6195f68cb61dad2/README.md#L570-L576

specifically, the stuff after the comma is leftover from when this was an I18n.t (maybe) copied from https://github.com/varvet/pundit/blob/a09548c826b85ced18a2e54ec6195f68cb61dad2/README.md#L529

the fix

a straightforward fix would just be deleting the stuff after the comma

e.g.

@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base

   rescue_from Pundit::NotAuthorizedError do |e| 
     message = e.reason ? I18n.t("pundit.errors.#{e.reason}") : e.message 
-    flash[:error] = message, scope: "pundit", default: :default 
+    flash[:error] = message
     redirect_to(request.referrer || root_path) 
   end

But based on my understanding of the conversation on PR #625, I think my PR modifies the example to accomplish the intended effect

astronaut-wannabe commented 3 years ago

just noticed there is already a PR for this (https://github.com/varvet/pundit/pull/638) closing and will comment on that one instead