README.md in action_policy-0.3.2 vs README.md in action_policy-0.3.3
- old
+ new
@@ -45,10 +45,12 @@
```ruby
class ApplicationPolicy < ActionPolicy::Base
end
```
+This may be done with `rails generate action_policy:install` generator.
+
Then write a policy for a resource. For example:
```ruby
class PostPolicy < ApplicationPolicy
# everyone can see any post
@@ -61,9 +63,11 @@
# `record` is a target object (post we want to update)
user.admin? || (user.id == record.user_id)
end
end
```
+
+This may be done with `rails generate action_policy:policy Post` generator.
Now you can easily add authorization to your Rails\* controller:
```ruby
class PostsController < ApplicationController