<?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>a work on process &#187; permalink_fu</title>
	<atom:link href="http://jystewart.net/process/tag/permalink_fu/feed/" rel="self" type="application/rss+xml" />
	<link>http://jystewart.net/process</link>
	<description>notes from another web developer</description>
	<lastBuildDate>Sat, 21 Aug 2010 13:09:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>More notes from a Rails 3.0pre upgrade</title>
		<link>http://jystewart.net/process/2010/01/more-notes-from-a-rails-3-0pre-upgrade/</link>
		<comments>http://jystewart.net/process/2010/01/more-notes-from-a-rails-3-0pre-upgrade/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 17:45:28 +0000</pubDate>
		<dc:creator>James Stewart</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[OpenID]]></category>
		<category><![CDATA[openid_authentication]]></category>
		<category><![CDATA[permalink_fu]]></category>
		<category><![CDATA[rails 3.0]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://jystewart.net/process/?p=680</guid>
		<description><![CDATA[This is a follow-on from my piece on how I got the (development version of) Catapult Magazine up and running with Rails 3.0pre. If you haven&#8217;t already done so, I&#8217;d recommend you read that first. Catapult makes use of the permalink_fu plugin which fails in Rails 3. It fails because of a reliance on the <a href="http://jystewart.net/process/2010/01/more-notes-from-a-rails-3-0pre-upgrade/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>This is a follow-on from my piece on how I got the (development version of) Catapult Magazine up and running with Rails 3.0pre. If you haven&#8217;t already done so, I&#8217;d recommend you <a href="/process/2009/12/upgrading-an-app-to-rails-3-0pre/">read that first</a>.</p>
<p>Catapult makes use of the <strong>permalink_fu</strong> plugin which fails in Rails 3. It fails because of a reliance on the evaluate_attribute_method method which no longer exists in version 3. I&#8217;ve temporarily worked around that by replacing it with class_eval, but lately I&#8217;ve been using friendly_id a lot more and I suspect I&#8217;ll be focussing on porting to that if <em>it</em> works cleanly in Rails 3.</p>
<p>*** </p>
<p>A dependency I&#8217;ve long wanted to part with is <strong>has_many_polymorphs</strong>. I&#8217;m using it to manage the categorisation of issues and posts but all that&#8217;s ever really saved me is one table/model, so perhaps now is the time to clean up the models and lose that dependency.</p>
<p>*** </p>
<p><strong>open_id_authentication</strong> uses a config.to_prepare block to include itself in ActionController::Base but that&#8217;ll work just as well if I add</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">include</span> OpenIdAuthentication</pre></div></div>

<p>to my ApplicationController, so that&#8217;s what I&#8217;ve done. I suspect a number of other changes will be needed (there&#8217;s a reference to config.gem in there) but so far, so good.</p>
<p>***</p>
<p>The key issue I&#8217;ve run into is that the init.rb files in my gem plugins aren&#8217;t run automatically, meaning that in addition, say, to declaring a model <q>has_attached_file</q> (for <strong>paperclip</strong>) I also need to <q>require &#8216;paperclip&#8217;</q>. That&#8217;s not totally unreasonable, but in a complex app it could be quite time consuming and begins to move away from the sense that a plugin/gem is a self-contained unit. </p>
<p>Looking through the new rails source I found the method that loads the init.rb files for plugins installed in vendor/plugins. Rails::Plugin::Vendored (in railties/lib/rails/plugin.rb) contains:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">initializer <span style="color:#ff3333; font-weight:bold;">:load_init_rb</span>, <span style="color:#ff3333; font-weight:bold;">:before</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:load_application_initializers</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>app<span style="color:#006600; font-weight:bold;">|</span>
  file   = <span style="color:#996600;">&quot;#{@path}/init.rb&quot;</span>
  config = app.<span style="color:#9900CC;">config</span>
  <span style="color:#CC0066; font-weight:bold;">eval</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#CC0066; font-weight:bold;">binding</span>, file <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">file</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>but that only looks through those, not gem plugins. It wouldn&#8217;t be too hard to add some code in the initializer to glob the relevant folder and load those files but I&#8217;ve not had time yet to decide if that&#8217;s my best way forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://jystewart.net/process/2010/01/more-notes-from-a-rails-3-0pre-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
