-
-
Save febuiles/31437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def some_filter | |
| redirect_unauthorized unless current_user.authorized?(@judge) | |
| end | |
| def redirect_unauthorized(where = "#{params[:controller]}_path", | |
| message = "You are not authorized to perform this action.") | |
| flash[:error] = message | |
| redirect_to where | |
| end | |
| ## This 404s in Safari although I get this in the console: | |
| Processing JudgesController#edit (for 127.0.0.1 at 2008-12-03 01:04:02) [GET] | |
| Parameters: {"id"=>"6"} | |
| User Load (0.6ms) SELECT * FROM "users" WHERE ("users"."id" = 4) LIMIT 1 | |
| Judge Load (0.4ms) SELECT * FROM "judges" WHERE ("judges"."id" = 6) | |
| Judge Exists (0.4ms) SELECT "judges".id FROM "judges" WHERE ("judges"."id" = 6) AND ("judges".owner_id = 4) LIMIT 1 | |
| Redirected to judges_path | |
| Filter chain halted as [:user_authorized?] rendered_or_redirected. | |
| Completed in 35ms (DB: 1) | 302 Found [http://localhost/judges/6/edit] | |
| ## If I use this everything works fine: | |
| def redirect_unauthorized(where = "#{params[:controller]}_path", | |
| message = "You are not authorized to perform this action.") | |
| flash[:error] = message | |
| redirect_to "/" | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment