docs/quick_start.md in action_policy-0.1.4 vs docs/quick_start.md in action_policy-0.2.0
- old
+ new
@@ -72,10 +72,18 @@
\* See [Non-Rails Usage](non_rails.md) on how to add `authorize!` to any Ruby project.
In the above case, Action Policy automatically infers a policy class and a rule to verify access: `@post -> Post -> PostPolicy`, rule is inferred from the action name (`update -> update?`), and `current_user` is used as `user` within the policy by default (read more about [authorization context](authorization_context.md)).
-When authorization is successful (i.e., the corresponding rule returns `true`), nothing happens, but in case of an authorization failure `ActionPolicy::Unauthorized` error is raised.
+When authorization is successful (i.e., the corresponding rule returns `true`), nothing happens, but in case of an authorization failure `ActionPolicy::Unauthorized` error is raised:
+
+```ruby
+rescue_from ActionPolicy::Unauthorized do |ex|
+ # Exception object contains the following information
+ ex.policy #=> policy class, e.g. UserPolicy
+ ex.rule #=> applied rule, e.g. :show?
+end
+```
There is also an `allowed_to?` method which returns `true` or `false` and could be used, for example, in views:
```erb
<% @posts.each do |post| %>