1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00

Mention second argument to authorize in README

This commit is contained in:
Jonas Nicklas 2012-11-19 13:06:48 +01:00
parent 4c234bb3a2
commit d13f6e6568

View file

@ -87,6 +87,18 @@ and the given record. It then infers from the action name, that it should call
raise "not authorized" unless PostPolicy.new(current_user, @post).create?
```
You can pass a second arguent to `authorize` if the name of the permission you
want to check doesn't match the action name. For example:
``` ruby
def publish
@post = Post.find(params[:id])
authorize @post, :update?
@post.publish!
redirect_to @post
end
```
You can easily get a hold of an instance of the policy through the `policy`
method in both the view and controller. This is especially useful for
conditionally showing links or buttons in the view: