Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Clearer documentation
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
nathanl committed Sep 21, 2013
1 parent c6a7f41 commit 2d18333
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions README.markdown
Expand Up @@ -397,15 +397,13 @@ class LlamasController < ApplicationController
end
```

Finally, if you want to ensure that all controller actions get authorized, you can use `ensure_authorization_performed`, which sets up an `after_filter` to raise an exception if it wasn't. Any `only` or `except` arguments will be passed to `after_filter`. You can also use `if` or `unless` to specify the name of a controller method which determines whether it's necessary.
Finally, you can enforce that every controller action runs an authorization check by using `ensure_authorization_performed`, which sets up an `after_filter` to raise an exception if it wasn't. Any `only` or `except` arguments will be passed to `after_filter`. You can also use `if` or `unless` to specify the name of a controller method which determines whether it's necessary.

Since this runs in an `after_filter`, it obviously doesn't prevent the action, it just alerts you that no authorization was performed. Therefore, it's most useful in development. An example usage might be:

```ruby
class ApplicationController < ActionController::Base
ensure_authorization_performed :except => [:index, :show]
# OR
ensure_authorization_performed :if => :user_seems_shifty?
# OR
ensure_authorization_performed :unless => :devise_controller?
ensure_authorization_performed :except => [:index, :search], :if => Rails.env.development?, :unless => :devise_controller?
end
```

Expand Down

0 comments on commit 2d18333

Please sign in to comment.