README.md in strong_actions-0.0.2 vs README.md in strong_actions-0.0.3
- old
+ new
@@ -16,24 +16,41 @@
$ gem install strong_actions
## Usage
+
+### Configuration
+
Suppose method "current_user" is available for controllers and views,
and user has an attribute called admin and only admin can modify resource "users",
then prepare config/acl.yml
current_user:
- users:
- new: admin?
- create: admin?
- edit: admin?
- update: admin?
- destroy: admin?
+ users:
+ new: admin?
+ create: admin?
+ edit: admin?
+ update: admin?
+ destroy: admin?
-In views, use helper_method "available?"
+In above case, when a non-admin user try to access new_user_path, StrongActions::ForbiddenAction is thrown.
+
+### Handling error in controller
+
+In application_controller.rb, the error should be rescued like
+
+ rescue_from StrongActions::ForbiddenAction do
+ render :file => 'public/403.html', :layout => false, :status => :forbidden
+ end
+
+In above case, all the forbidden accesses are handled by public/403.html.
+
+### Disabling forbidden link in view
+
+In views, use helper method "available?" so that links for forbidden actions are not shown.
<%= link_to 'Add User' new_user_path if available?('users', 'new') %>
## Contributing