README.textile in restful_acl-2.1.0 vs README.textile in restful_acl-2.1.1
- old
+ new
@@ -17,13 +17,12 @@
Add the gem to your environment.rb file as thus:
<pre>config.gem "mdarby-restful_acl", :lib => 'restful_acl_controller'</pre>
RESTful_ACL requires two named routes: "error" and "denied". Add the following to your routes.rb file:
-<pre>
- map.error 'error', :controller => 'some_controller', :action => 'error_action'
- map.denied 'denied', :controller => 'some_controller', :action => 'denied_action'
+<pre> map.error 'error', :controller => 'some_controller', :action => 'error_action'
+map.denied 'denied', :controller => 'some_controller', :action => 'denied_action'
</pre>
h3. How to Use
h4. Controllers
@@ -38,36 +37,31 @@
class Issue < ActiveRecord::Base
logical_parent :some_model_name
# This method checks permissions for the :index action
def self.is_indexable_by(user, parent = nil)
-
end
# This method checks permissions for the :create and :new action
def self.is_creatable_by(user, parent = nil)
-
end
# This method checks permissions for the :show action
def is_readable_by(user, parent = nil)
-
end
# This method checks permissions for the :update and :edit action
def is_updatable_by(user, parent = nil)
-
end
# This method checks permissions for the :destroy action
def is_deletable_by(user, parent = nil)
-
end
end
</pre>
-h5. Singleton Resources
+h4. Singleton Resources
RESTful_ACL 2.1+ supports singleton resources. Just pass @:singleton@ to the @logical_parent@
<pre>
class Car < ActiveRecord::Base
@@ -77,16 +71,15 @@
</pre>
h4. View Helpers
There are five view helpers also included in RESTful_ACL: @#indexable@, @#creatable@, @#readable@, @#updatable@, and @#deletable@. These enable you to do nifty things like:
-<pre>
- <%= link_to ‘Foo Index’, foos_path if indexable %>
- <%= link_to 'Edit Foo', edit_foo_path(@foo) if updatable(@foo) %>
- <%= link_to 'Create Foo', new_foo_path if creatable %>
- <%= link_to 'View Foo', foo_path(@foo) if readable(@foo) %>
- <%= link_to 'Delete Foo', foo_path(@foo) if deletable(@foo), :method => :destroy %>
+<pre>= link_to ‘Foo Index’, foos_path if indexable
+= link_to 'Edit Foo', edit_foo_path(@foo) if updatable(@foo)
+= link_to 'Create Foo', new_foo_path if creatable
+= link_to 'View Foo', foo_path(@foo) if readable(@foo)
+= link_to 'Delete Foo', foo_path(@foo) if deletable(@foo), :method => :destroy
</pre>
h3. Huh? Here's an example
Let's say that you have two resources: Project and Issue. A Project has many Issues, an Issue belongs to a Project. I'd like to make sure that the current user is a member of the Project before they can create a new Issue in that Project:
@@ -161,6 +154,6 @@
h3. About the Author
My name is "Matt Darby.":http://blog.matt-darby.com I’m an IT Manager and pro-web-dev at for "Dynamix Engineering":http://dynamix-ltd.com and hold a Master’s Degree in Computer Science from "Franklin University":http://www.franklin.edu in sunny "Columbus, OH.":http://en.wikipedia.org/wiki/Columbus,_Ohio
-Feel free to check out my "blog":http://blog.matt-darby.com or "recommend me":http://www.workingwithrails.com/person/10908-matt-darby
+Feel free to check out my "blog":http://blog.matt-darby.com or "recommend me":http://www.workingwithrails.com/person/10908-matt-darby
\ No newline at end of file