<?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>CrudVision - Lisa Seelye &#187; rails</title>
	<atom:link href="http://www.crudvision.com/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crudvision.com</link>
	<description>Lisa Seelye's Blog. Yay</description>
	<lastBuildDate>Tue, 13 Apr 2010 21:26:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Moving away from SVN</title>
		<link>http://www.crudvision.com/2009/04/26/moving-away-from-svn/</link>
		<comments>http://www.crudvision.com/2009/04/26/moving-away-from-svn/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 03:20:11 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[blog]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[eve online]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[reve]]></category>
		<category><![CDATA[rock climbing]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/?p=129</guid>
		<description><![CDATA[I will no longer be updating svn here at crudvision.com. I want to move Reve to git (at github). I won&#8217;t do it if I can fall back to svn, so I&#8217;m jumping ship. Moving to github will also mean I can dump dreamhost as a host and move crudvision.com to my colocated machine to [...]]]></description>
			<content:encoded><![CDATA[<p>I will no longer be updating svn here at crudvision.com. I want to move Reve to git (at <a href="http://github.com/lisa/reve/tree/master">github</a>). I won&#8217;t do it if I can fall back to svn, so I&#8217;m jumping ship.</p>
<p>Moving to github will also mean I can dump dreamhost as a host and move crudvision.com to my colocated machine to save money each month.</p>
<p>I&#8217;m sorry for the complete void in posting. I&#8217;ve been very busy with life, work and rock climbing. Yes, that&#8217;s right, rock climbing.</p>
<p>In early March I started a new job in Toronto for a gaming company (I&#8217;m not really allowed to talk about it much, unfortunately). I&#8217;m a sysadmin there and I love it. It&#8217;s much better than developing the same web applications over and over. I&#8217;m almost ready to resume programming for a hobby now that I don&#8217;t do it all day every day for pay.</p>
<p>And the rock climbing. My partner and I started climbing recently. We&#8217;ve noticed an unusual number of IT professionals that climb! It&#8217;s cool and odd at the same time.</p>
<p>I hope to post more, but the real goal of the post is to say that I&#8217;m ditching subversion, trac and intend to use github as the only source of documentation for Reve. (I just hope I can get traffic from github to this blog to pad my ego.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2009/04/26/moving-away-from-svn/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixtures in Rails Suck &#8211; this makes them suck less</title>
		<link>http://www.crudvision.com/2008/07/30/fixtures-in-rails-suck/</link>
		<comments>http://www.crudvision.com/2008/07/30/fixtures-in-rails-suck/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 01:31:20 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/?p=108</guid>
		<description><![CDATA[If you've got a boat load of legacy fixtures laying around (and who doesn't?) it can be a pain now that Rails handles the ID of objects so you don't have to. On the train back from holiday I wrote a snippet of code to migrate them: PLAIN TEXT RUBY: def Util.real_yml&#40;klass,col = 'name'&#41; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>If you've got a boat load of legacy fixtures laying around (and who doesn't?) it can be a pain now that Rails handles the ID of objects so you don't have to.</p>
<p>On the train back from holiday I wrote a snippet of code to migrate them:</p>
<div class="igBar"><span id="lruby-3"><a href="#" onclick="javascript:showCodeTxt('ruby-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-3">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> Util.<span style="color:#9900CC;">real_yml</span><span style="color:#006600; font-weight:bold;">&#40;</span>klass,col = 'name'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; y = YAML.<span style="color:#9900CC;">load_file</span><span style="color:#006600; font-weight:bold;">&#40;</span>File.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span>RAILS_ROOT,'<span style="color:#CC0066; font-weight:bold;">test</span>','fixtures',<span style="color:#996600;">"#{klass.to_s.tableize}.yml"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; real_names = y.<span style="color:#9900CC;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |names,<span style="color:#006600; font-weight:bold;">&#40;</span>key,val<span style="color:#006600; font-weight:bold;">&#41;</span>| names &lt;&lt;y<span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>col<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> y<span style="color:#006600; font-weight:bold;">&#91;</span>key<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>col<span style="color:#006600; font-weight:bold;">&#93;</span> ;names&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; real_objs = klass.<span style="color:#9900CC;">find</span> :all, :conditions =&gt; <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">"#{col} IN (?)"</span>,real_names <span style="color:#006600; font-weight:bold;">&#93;</span>, <img src='http://www.crudvision.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&gt; <span style="color:#996600;">"#{col} asc"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; yml = <span style="color:#996600;">""</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; real_objs.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |real_obj|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; yml += <span style="color:#996600;">"#{real_obj.name.downcase.gsub(' ','_').gsub('-','')}:<span style="color:#000099;">\n</span>"</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; real_obj.<span style="color:#9900CC;">attributes</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |k,v|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> k =~ /_id$/ &amp;&amp; real_obj.<span style="color:#9900CC;">respond_to</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>k.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>/_id$/,''<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_sym</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; ! v.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n_klass = k.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>/_id$/,''<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">camelize</span>.<span style="color:#9900CC;">constantize</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>v<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#0000FF; font-weight:bold;">nil</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key = k.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>/_id$/,''<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val = n_klass.<span style="color:#9900CC;">name</span>.<span style="color:#9900CC;">downcase</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>' ','_'<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>'-',''<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yml += <span style="color:#996600;">"&nbsp; #{key}: #{val}<span style="color:#000099;">\n</span>"</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yml += <span style="color:#996600;">"&nbsp; #{k}: #{v}<span style="color:#000099;">\n</span>"</span> <span style="color:#9966CC; font-weight:bold;">unless</span> k.<span style="color:#9900CC;">to_s</span> == 'id'</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; yml</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The use is:</p>
<div class="igBar"><span id="lruby-4"><a href="#" onclick="javascript:showCodeTxt('ruby-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-4">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'util'</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">print</span> Util.<span style="color:#9900CC;">real_yml</span><span style="color:#006600; font-weight:bold;">&#40;</span>Corporation<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Copy/paste into corporations.yml</p>
<p>So far it's working great!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/07/30/fixtures-in-rails-suck/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The decline of Rails-Core mail list</title>
		<link>http://www.crudvision.com/2008/07/29/the-decline-of-rails-core-mail-list/</link>
		<comments>http://www.crudvision.com/2008/07/29/the-decline-of-rails-core-mail-list/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 15:35:38 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[dspam]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[ham]]></category>
		<category><![CDATA[mail lists]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails-core]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/?p=106</guid>
		<description><![CDATA[Lately the rails-core mail list has declined in quality. Spammers have moved in and operate unfettered. Reporting offenders to Google does nothing. In fact, in order to isolate my personal mail from spam and to keep dspam from getting very confused I've moved the rails-core list to a google mail account. It's a shame but [...]]]></description>
			<content:encoded><![CDATA[<p>Lately the <a href="http://groups.google.com/group/rubyonrails-core">rails-core</a> mail list has declined in quality. Spammers have moved in and operate unfettered. Reporting offenders to Google does nothing.</p>
<p>In fact, in order to isolate my personal mail from spam and to keep <a href="http://dspam.nuclearelephant.com/">dspam</a> from getting very confused I've moved the rails-core list to a google mail account. It's a shame but I'm more interested in keeping my other mail free from spam and the dspam quarantine free from ham. Isolation of rails-core until Google can get the spammers off their lists will accomplish the goal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/07/29/the-decline-of-rails-core-mail-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini Match is Alive!</title>
		<link>http://www.crudvision.com/2008/06/03/mini-match-is-alive/</link>
		<comments>http://www.crudvision.com/2008/06/03/mini-match-is-alive/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 11:14:49 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/?p=100</guid>
		<description><![CDATA[Yesterday we launched Mini Match, an application me and my colleagues from work wrote for Cartoon Network. Late last year we opened a beta that was, unfortunately, short lived. Friday (May 30, 2008) we opened the system up on a much improved codebase for a few hours and had all systems "green". Based on the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we launched <a href="http://minimatch.cartoonnetwork.com">Mini Match</a>, an application me and my colleagues from work wrote for Cartoon Network.</p>
<p>Late last year we opened a beta that was, unfortunately, short lived. Friday (May 30, 2008) we opened the system up on a much improved codebase for a few hours and had all systems "green". Based on the positive success from Friday we opened it up yesterday.</p>
<p>It opened slowly at first with just a small advertisement on the <a href="http://www.cartoonnetwork.com/games/index.html">Cartoon Network Games' Page</a>, and then a larger one on the same page and then we made the <a href="http://www.cartoonnetwork.com">Cartoon Network home page</a> with a small advertisement again. Today, I reckon, a larger advertisement will be put on the front page and we'll really start to see traffic!</p>
<p>Some details on the application:</p>
<ul>
<li>Flash/Flex/AS/Whatever front-end GUI (really, it's one of them)</li>
<li>Java-based persistance server</li>
<li>Rails-based funnel into the database with a bit of logic.</li>
</ul>
<p>The Rails part is RESTful (for the most part) and is the "glue" of the application, to quote someone from IRC.</p>
<p>Today should be a fun day!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/06/03/mini-match-is-alive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Off to Atlanta</title>
		<link>http://www.crudvision.com/2008/05/24/off-to-atlanta/</link>
		<comments>http://www.crudvision.com/2008/05/24/off-to-atlanta/#comments</comments>
		<pubDate>Sat, 24 May 2008 14:24:52 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[beta]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[travel]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/?p=99</guid>
		<description><![CDATA[This coming Monday I'm flying off to Atlanta, Georgia for the week. Not keen on going as Atlanta is like descending into the armpit of summer. I'm hoping that the weather co-operates and I don't melt. I'm flying down there for work, we're beta launching a product for a customer (that's based in Atlanta - [...]]]></description>
			<content:encoded><![CDATA[<p>This coming Monday I'm flying off to Atlanta, Georgia for the week. Not keen on going as Atlanta is like descending into the armpit of summer. I'm hoping that the weather co-operates and I don't melt. <img src='http://www.crudvision.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I'm flying down there for work, we're beta launching a product for a customer (that's based in Atlanta - go figure) and they (the customer) have requested a contingent of us from work be on site for the release. So it's me and two others from the UK.</p>
<p>We're down on Monday then flying back home on Friday evening - I'm hoping to be in bed by midnight (landing 22:05 - 30 minute taxi home, getting bags and immigration and such). A SysAdmin that works for our customer suggested <a href="http://www.zumasushibar.com/">Zuma sushi bar</a> to me for sushi. I like sushi a lot and hope to stop in for some glorious sushi.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/05/24/off-to-atlanta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Reve Trac Ticket</title>
		<link>http://www.crudvision.com/2008/02/17/first-reve-trac-ticket/</link>
		<comments>http://www.crudvision.com/2008/02/17/first-reve-trac-ticket/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 10:58:20 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[eve online]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[reve]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/2008/02/17/first-reve-trac-ticket/</guid>
		<description><![CDATA[Had my first bug report today about the to_i method I made on the String class breaking Rails migrations because leading zeroes weren't being treated nicely in my method: "001".to_i # => 1 and fails the test 1.to_s == "001" and so a String was being returned fromto_i. Crap. I don't think that I need [...]]]></description>
			<content:encoded><![CDATA[<p>Had my first <a href="http://revetrac.crudvision.com/ticket/1">bug report today</a> about the <code>to_i</code> method I made on the String class breaking Rails migrations because leading zeroes weren't being treated nicely in my method: <code>"001".to_i # => 1</code> and fails the test <code>1.to_s == "001"</code> and so a String was being returned from<code>to_i</code>. Crap.</p>
<p>I don't think that I need the method anyways (I'm going to spend part of today to make sure with more tests!) so I've removed it and tagged <a href="http://revetrac.crudvision.com/browser/tags/rel_80">Release 80</a> and uploaded <a href="http://rubyforge.org/frs/download.php/32529/reve-0.0.80.gem">the gem to RubyForge</a>. It should be available to <code>gem update</code> or <code>gem install</code> shortly.</p>
<p>This release also has a larger test coverage and some other unnecessary methods were pruned. Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/02/17/first-reve-trac-ticket/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An evil snippet for hash traversal</title>
		<link>http://www.crudvision.com/2008/02/09/an-evil-snippet-for-hash-traversal/</link>
		<comments>http://www.crudvision.com/2008/02/09/an-evil-snippet-for-hash-traversal/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 11:28:40 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[json]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/2008/02/09/an-evil-snippet-for-hash-traversal/</guid>
		<description><![CDATA[First the problem: I'm writing a load test framework at work and I need to consume JSON webservice and pass on the output to another request. But I don't always know what the data is that I need to pass on but I do know the basic "path" ("hpath" -- "hash path") to get to [...]]]></description>
			<content:encoded><![CDATA[<p>First the problem:</p>
<p>I'm writing a load test framework at work and I need to consume JSON webservice and pass on the output to another request. But I don't always know what the data is that I need to pass on but I do know the basic "path" ("hpath" -- "hash path") to get to the data as the JSON data is uniform.</p>
<p>Now the method:</p>
<div class="igBar"><span id="lruby-6"><a href="#" onclick="javascript:showCodeTxt('ruby-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-6">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># Picks out data from a (JSON) decoded hash based on the @passon hash,</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># which looks like this:</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># { &quot;id&quot; =&gt; &quot;packet.products[0].attributes.id&quot;, </span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#&nbsp; &nbsp;&quot;quantity&quot; =&gt; &quot;packet.products[0].attributes.quantity&quot; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># }</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># The &quot;id&quot; and &quot;quantity&quot; are the new keys for the return data;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># packet.products[0].attributes.id will look at the value of the id key</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># in the attributes hash in the 0th element of the products array in the</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># packet hash.</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> pick_out_passon<span style="color:#006600; font-weight:bold;">&#40;</span>hash_data<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> @passon</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; returnhash = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; nh = hash_data.<span style="color:#9900CC;">dup</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; @passon.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |newkey,part_str|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; parts = part_str.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"."</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">reverse</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span>part = parts.<span style="color:#9900CC;">pop</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; m = part.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>/\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d+<span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">&#93;</span>/<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; index = <span style="color:#0000FF; font-weight:bold;">nil</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> m</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; index = m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; part.<span style="color:#CC0066; font-weight:bold;">gsub</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>/\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#008000; font-style:italic;">#{m[0]}\]/,'')</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; nh = nh.<span style="color:#9900CC;">values_at</span><span style="color:#006600; font-weight:bold;">&#40;</span>part<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; nh = nh.<span style="color:#9900CC;">at</span><span style="color:#006600; font-weight:bold;">&#40;</span>index<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> index</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; returnhash.<span style="color:#9900CC;">merge</span>!<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span> newkey=&gt; nh<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nh = hash_data.<span style="color:#9900CC;">dup</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; returnhash</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>What's it do? It does magic!</p>
<p>I'll step through it...</p>
<p>Looks for @passon instance variable and doesn't do anything useful unless it exists.</p>
<p>Duplicate the input hash because the process done is destructive to it and we may need to reuse it.</p>
<p>For each  new hash key and "hpath" pair from @passon split up the hpath into its parts and reverse it so Array#pop will work in the while loop to get the next first part to try.</p>
<p>Since each part of the hpath can examine an Array by index it has to be checked for and the index removed from the part (and saved).</p>
<p>Next, investigate the copy of the hash_data, <code>nh</code> by the computed key; if the value in the hash was an Array use the index to get the desired value. Then compute the next part!</p>
<p>Once we're out of parts stuff the new key and data into the <code>returnhash</code> and keep going til there's no more @passon pairs.</p>
<p>And thus some fun code was written.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/02/09/an-evil-snippet-for-hash-traversal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reve Release 61</title>
		<link>http://www.crudvision.com/2008/01/13/reve-release-61/</link>
		<comments>http://www.crudvision.com/2008/01/13/reve-release-61/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 14:55:27 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[eve online]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[reve]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/2008/01/13/reve-release-61/</guid>
		<description><![CDATA[Reve release 61 is full of changes and new features. Highlighting them is Reve now has a Trac and its home page here on my blog will eventually be migrated over to the Trac including code samples and more comprehensive documentation. A brief list of what's changed is: Corporations now nest under the Reve::API#alliances call [...]]]></description>
			<content:encoded><![CDATA[<p>Reve release 61 is <a href="http://revetrac.crudvision.com/log/trunk?action=stop_on_copy&#038;rev=61&#038;stop_rev=40&#038;mode=stop_on_copy&#038;verbose=on">full of changes and new features.</a> Highlighting them is Reve now has a <a href="http://revetrac.crudvision.com/">Trac</a> and its home page here on my blog will eventually be migrated over to the Trac including code samples and more comprehensive documentation.</p>
<p>A brief list of what's changed is:</p>
<ul>
<li>Corporations now nest under the <a href="http://docs.crudvision.com/reve/classes/Reve/API.html#M000070">Reve::API#alliances</a> call and their ID can be passed to <a href="http://docs.crudvision.com/reve/classes/Reve/API.html#M000097">Reve::API#corporation_sheet</a> to get more info from about the Corporation.</li>
<li>Added an <a href="http://revetrac.crudvision.com/browser/trunk/init.rb">init.rb</a> so people can install Reve as a plugin to a Rails application (Saves having to put it in lib and constantly update it. See <a href="http://revetrac.crudvision.com/wiki/RailsPlugin">RailsPlugin on the trac</a> for details. Thanks to <a href="http://www.talkunafraid.co.uk/">James Harrison</a> for the idea.</li>
<li>Reading of XML from an arbitrary source for all API calls. Including a file on disk or any other website. Useful for integrating with a caching proxy.</li>
<li>Saving of XML to disk after a successfully completed API call. Useful to report bugs and to cache things locally. See the previous point!</li>
</ul>
<p>The <a href="http://docs.crudvision.com/reve">RDOC for Reve</a> has been updated as well.</p>
<p>Download:</p>
<ul>
<li><a href='http://www.crudvision.com/wp-content/uploads/2008/01/rel_61.tgz' title='Reve Release 61 in .tgz format'>Reve Release 61 in .tgz format</a></li>
<li><a href='http://www.crudvision.com/wp-content/uploads/2008/01/rel_61.zip' title='Reve Release 61 in .zip format'>Reve Release 61 in .zip format</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/01/13/reve-release-61/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Followup to My First Patch</title>
		<link>http://www.crudvision.com/2008/01/02/followup-to-my-first-patch/</link>
		<comments>http://www.crudvision.com/2008/01/02/followup-to-my-first-patch/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 16:50:38 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/2008/01/02/followup-to-my-first-patch/</guid>
		<description><![CDATA[In reference to the post about My First Patch to the Rails trac I mentioned in the edit of the post that I emailed the maintainer. There's been no response, unfortunately. So I'll post the patch here so it'll get a bit more visibility and hopefully Oracle users can find it helpful in speeding up [...]]]></description>
			<content:encoded><![CDATA[<p>In reference to the post about <a href="http://www.crudvision.com/2007/12/01/my-first-patch/">My First Patch</a> to the <a href="http://dev.rubyonrails.org/ticket/10331">Rails trac</a> I mentioned in the edit of the post that I emailed the maintainer. There's been no response, unfortunately.</p>
<p>So I'll post the patch here so it'll get a bit more visibility and hopefully Oracle users can find it helpful in speeding up <code>rake db:migrate</code> on Oracle systems with a lot of indicies.</p>
<p><a href='http://www.crudvision.com/wp-content/uploads/2008/01/change_oracleadapter_indexes_to_run_quicker.diff' title='Patch to speed up Rails’s OracleAdapter#indexes method'>Patch to speed up Rails’s OracleAdapter#indexes method</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2008/01/02/followup-to-my-first-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails has_many gotcha</title>
		<link>http://www.crudvision.com/2007/12/08/rails-has_many-gotcha/</link>
		<comments>http://www.crudvision.com/2007/12/08/rails-has_many-gotcha/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 13:39:04 +0000</pubDate>
		<dc:creator>Lisa Seelye</dc:creator>
				<category><![CDATA[activerecord]]></category>
		<category><![CDATA[crud]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.crudvision.com/2007/12/08/rails-has_many-gotcha/</guid>
		<description><![CDATA[With Rails there's a useful set of callback methods that can be used within model classes. They include after_create, before_validation and the one I want to talk about after_initialize. A lot of cool things can be done with after_initialize, especially if one uses the database as a means to store meta-data about a model. Use [...]]]></description>
			<content:encoded><![CDATA[<p>With Rails there's a useful set of <a href="http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html">callback methods</a> that can be used within model classes. They include <code>after_create</code>, <code>before_validation</code> and the one I want to talk about <code>after_initialize</code>.</p>
<p>A lot of cool things can be done with <code>after_initialize</code>, especially if one uses the database as a means to store meta-data about a model. Use the <code>after_initialize</code> method to transform your models with Ruby after they're fethced from the database. Consider the following User model definition:</p>
<div class="igBar"><span id="lruby-9"><a href="#" onclick="javascript:showCodeTxt('ruby-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-9">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> User &lt;ActiveRecord::Base</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; has_many :memberships, <img src='http://www.crudvision.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&gt; <span style="color:#996600;">"memberships.group_id, memberships.expires_at desc"</span>, :group =&gt; <span style="color:#996600;">"group_id"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It's pretty clear that with the <code>:group => "group_id"</code> that I want a unique set of Membership objects. That works well when I've already got a User and do <code>user.memberships</code> but not at all when I do <code>User.find(:first, :include => :memberships)</code>; likely because of the way the join is set up and grouping on that may not be possible.</p>
<p>I still wanted to use eager loading so I thought that it would be an OK sacrifice to fetch all the Membership objects even if I wanted to pare it down after I initialize the User object (with eager loading). I defined:</p>
<div class="igBar"><span id="lruby-10"><a href="#" onclick="javascript:showCodeTxt('ruby-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-10">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> User &lt;ActiveRecord::Base</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> after_initialize</div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">do</span> stuff with @memberships instance varible</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#EB7070;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#8970EB;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Except it doesn't work. Quickly I found the following from <a href="http://dev.rubyonrails.org/browser/tags/rel_2-0-0_RC2/activerecord/lib/active_record/base.rb#L1140">active_record/base.rb</a> (click link for source): right where it does the after_initialize callback! But it wasn't working for me. I needed to dig further.</p>
<p>Further research indicated that before the creation of the @memberships instance variable that would hold the collection of Membership objects the after_initialize callback was being fired off in the User model. Using <code>after_initialize</code> would not work due to the design of ActiveRecord. I'm still searching for an elegant way to work the way I want. I'll post again when I find it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crudvision.com/2007/12/08/rails-has_many-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.460 seconds -->
