<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Wood for the Trees: Simple Access Control: First Release</title>
    <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>struggling to dig life</description>
    <item>
      <title>Simple Access Control: First Release</title>
      <description>&lt;p style="text-align:justify;"&gt;In keeping with my promise from the previous post on acl_system2 and the new access control system I created, I&amp;#8217;ve released it as a plugin:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_shell "&gt;script/plugin install http://mabs29.googlecode.com/svn/trunk/plugins/simple_access_control&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p style="text-align:justify;"&gt;It&amp;#8217;s usage is very intuitive:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;ApplicationController&lt;/span&gt;
&lt;span class="ident"&gt;access_rule&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;admin&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:only&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="symbol"&gt;:create&lt;/span&gt;
&lt;span class="ident"&gt;access_rule&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;moderator || admin&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:only&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p style="text-align:justify;"&gt;Treat it just like a before filter. Your rules are composed of titles, which require you to have a Role model with a has_and_belongs_to_many relationship with your user model (you may name your user model anything you like, but it is vital that you have an accessor called current_user). You also get a few freebies, like restrict_to(rule, &amp;#38;block), has_permission?(rule, user = current_user), and two backward compatible commands for acl_system2 users: access_control and permit?.&lt;/p&gt;


	&lt;p style="text-align:justify;"&gt;If you need more pointers, all of this is explained in the &lt;span class="caps"&gt;README&lt;/span&gt;.&lt;/p&gt;</description>
      <pubDate>Fri, 28 Jul 2006 13:29:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5e8be2a3-8ff7-4736-8d89-17639ee2a2fb</guid>
      <author>Mathew Abonyi</author>
      <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release</link>
      <category>Rails</category>
      <trackback:ping>http://www.mathewabonyi.com/articles/trackback/14</trackback:ping>
    </item>
    <item>
      <title>"Simple Access Control: First Release" by Cham</title>
      <description>&lt;p&gt;Okay finally worked this out, I had a role which has a empty string for the title. Makes sense now looking at the error!!&lt;/p&gt;</description>
      <pubDate>Wed, 21 Nov 2007 09:07:29 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:80eb68a0-b6c2-4dc3-bece-5822289b1018</guid>
      <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release#comment-24389</link>
    </item>
    <item>
      <title>"Simple Access Control: First Release" by Cham</title>
      <description>&lt;p&gt;I have been using your simple_access_control plugin successfully until I checked my code out on a different machine (same ruby version and rails is frozen to 1.2.3) now I get errors. I wonder if you could point me in the right direction as to what is wrong?&lt;/p&gt;


	&lt;p&gt;If you have time I would be very thankful.&lt;/p&gt;


	&lt;p&gt;CODE: 
&amp;lt;% restrict_to &amp;#8216;admin || manager || report_viewer&amp;#8217; do %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;/p&gt;


	&lt;p&gt;ERROR:
./script/../config/../vendor/plugins/simple_access_control/lib/simple_access_control.rb:123:in `check&amp;#8217;: You have a nil object when you didn&amp;#8217;t expect it!
The error occurred while evaluating nil.downcase&lt;/p&gt;


	&lt;p&gt;STACK:
vendor/plugins/simple_access_control/lib/simple_access_control.rb:107:in `process&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `map&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `send&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `method_missing&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:91:in `method_missing&amp;#8217;
vendor/plugins/simple_access_control/lib/simple_access_control.rb:123:in `check&amp;#8217;
(eval):1:in `process&amp;#8217;
(eval):2:in `send&amp;#8217;
(eval):2:in `restrict_to&amp;#8217;
#{RAILS_ROOT}/app/views/account/index.rhtml:19:in `_run_rhtml_47app47views47account47index46rhtml&amp;#8217;
-e:4:in `load&amp;#8217;
-e:4&lt;/p&gt;


	&lt;p&gt;&amp;#8212;&amp;#8212;&lt;/p&gt;


	&lt;p&gt;CODE:
access_rule &amp;#8216;data_entry || manager || admin&amp;#8217;&lt;/p&gt;


	&lt;p&gt;ERROR:
vendor/plugins/simple_access_control/lib/simple_access_control.rb:123:in `check&amp;#8217;: You have a nil object when you didn&amp;#8217;t expect it!
The error occurred while evaluating nil.downcase&lt;/p&gt;


	&lt;p&gt;STACK:
vendor/plugins/simple_access_control/lib/simple_access_control.rb:107:in `process&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `map&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `send&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `method_missing&amp;#8217;
vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:91:in `method_missing&amp;#8217;
vendor/plugins/simple_access_control/lib/simple_access_control.rb:123:in `check&amp;#8217;
(eval):1:in `process&amp;#8217;
-e:4:in `load&amp;#8217;
-e:4&lt;/p&gt;</description>
      <pubDate>Wed, 24 Oct 2007 08:13:12 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9d45b2f0-6cd7-4cdf-8a6b-6907de571679</guid>
      <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release#comment-16107</link>
    </item>
    <item>
      <title>"Simple Access Control: First Release" by Jenman</title>
      <description>&lt;p&gt;When I try to use this plugin, I get a:&lt;/p&gt;


	&lt;p&gt;uninitialized constant User::Role&lt;/p&gt;


	&lt;p&gt;error. There&amp;#8217;s no Role model of course, so where is that supposed to come from?&lt;/p&gt;


	&lt;p&gt;This plugin needs a little setup how-to&amp;#8230;not enough documentation.&lt;/p&gt;</description>
      <pubDate>Wed, 22 Aug 2007 09:54:26 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:efeea661-91bd-4174-822a-632ec1e74b67</guid>
      <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release#comment-512</link>
    </item>
    <item>
      <title>"Simple Access Control: First Release" by Cal Atiyeh</title>
      <description>&lt;p&gt;This plugin is the most straight forward and effeicient (low weight) access control every made, I love it.&lt;/p&gt;</description>
      <pubDate>Wed, 15 Aug 2007 17:01:25 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:95d47b37-bd72-4a7e-ae8c-f18ee04f7a60</guid>
      <link>http://www.mathewabonyi.com/articles/2006/07/28/simple-access-control-first-release#comment-372</link>
    </item>
  </channel>
</rss>
