<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I'm a Richardson, RU? &#187; plugins</title>
	<atom:link href="http://www.imarichardson.com/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.imarichardson.com</link>
	<description>(ugh...really cool tagline goes here)</description>
	<lastBuildDate>Sat, 21 Aug 2010 16:36:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Declarative Association with HABTM Relationships</title>
		<link>http://www.imarichardson.com/2009/08/03/using-declarative-association-with-habtm-relationships/</link>
		<comments>http://www.imarichardson.com/2009/08/03/using-declarative-association-with-habtm-relationships/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 17:10:01 +0000</pubDate>
		<dc:creator>imarichardson</dc:creator>
				<category><![CDATA[Programming &#038; Development]]></category>
		<category><![CDATA[declarative authentication]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.imarichardson.com/?p=325</guid>
		<description><![CDATA[For anyone out there trying to use the Declarative Authentication with a standard "Has and Belongs To Many" relationship here's a quick help.]]></description>
			<content:encoded><![CDATA[<p>In my search for an authorization/access control list solution for my Ruby needs I came across Steffen Bartsch&#8217;s &#8220;<a href="http://steffenbartsch.com/blog/2008/09/delclarative-authorization/">Declarative Authorization</a>&#8221; plugin (<a href="http://github.com/stffn/declarative_authorization/tree/master">Github source here</a>).</p>
<p>Short aside &#8230; the plugin allows for a very DRY approach to managing permission from one configuration file, not to mention that it generates a visualization of your ACL, too. This is a huge benefit when building an app that has a number of different security roles. Additionally, it allows access control on the controller, model, query, and view levels. From the site:</p>
<blockquote><p>Plugin features</p>
<ul>
<li>Authorization at controller action level</li>
<li>Authorization helpers for Views</li>
<li>Authorization at model level
<ul>
<li>Authorize CRUD (Create, Read, Update, Delete) activities</li>
<li>Query rewriting to automatically only fetch authorized records</li>
</ul>
</li>
</ul>
</blockquote>
<p>I was ecstatic about using the plugin but hit a stump when trying to work it out with my own HABTM association in my Rails app. The third requirements mentions, &#8220;User objects need to respond to a method :role_symbols that returns an array of role symbols&#8221;. My log error kept displaying:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">The use of user.roles is deprecated. &nbsp;Please add a method role_symbols to your User model.<br />
Permission denied: User.roles doesn't return an Array of Symbols ([#])<br />
Filter chain halted as [:filter_access_filter] rendered_or_redirected.</div></td></tr></tbody></table></div>
<p>In order to get things to work correctly with a User model, Roles model, and Roles_Users table for the &#8220;has_and_belongs_to_many&#8221; relationship, you need to make sure you&#8217;ve a method in your user model that &#8220;correctly&#8221; generates a &#8220;roles_symbol&#8221; array:<br />
<script src="http://gist.github.com/160692.js"></script></p>
<p><strong>Note</strong>: Make sure that you use the correct value of the filed in your roles model when serializing. The example used &#8220;title&#8221; but in my application I used &#8220;name&#8221; for the column that defined the role.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.imarichardson.com/2009/08/03/using-declarative-association-with-habtm-relationships/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
