Created
May 15, 2013 22:50
-
-
Save delba/5588057 to your computer and use it in GitHub Desktop.
Raising an exception if an action isn't explicitly authorized
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
| class ApplicationController < ActionController::Base | |
| # ... | |
| include AuthorizationSystem | |
| after_filter :validate_authorization_checked | |
| end |
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
| class MessagesController < ApplicationController | |
| # ... | |
| def show | |
| @account = Account.find(params[:account_id]) | |
| @message = @account.messages.find(params[:id]) | |
| authorize! { current_user.can_view?(@message) } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment