<?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>steveshaw.ca</title>
	<atom:link href="http://steveshaw.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://steveshaw.ca</link>
	<description>Clever tagline here.</description>
	<lastBuildDate>Sun, 06 May 2012 19:58:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>And then the Bixi rep implied my wife was an idiot.</title>
		<link>http://steveshaw.ca/2012/05/06/and-then-the-bixi-rep-implied-my-wife-was-an-idiot/</link>
		<comments>http://steveshaw.ca/2012/05/06/and-then-the-bixi-rep-implied-my-wife-was-an-idiot/#comments</comments>
		<pubDate>Sun, 06 May 2012 19:55:15 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Bitching]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=80</guid>
		<description><![CDATA[On the way to see The Avengers today, my wife suggested that we rent Bixis and see if we liked them. Here&#8217;s what we liked: it was easy to pay for our bikes Here&#8217;s what we didn&#8217;t like: we couldn&#8217;t &#8230; <a href="http://steveshaw.ca/2012/05/06/and-then-the-bixi-rep-implied-my-wife-was-an-idiot/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2012/05/BIXI_TORONTO-RGB-1024x423.jpg"><img class="alignright size-medium wp-image-81" style="margin-top: 10px; margin-bottom: 10px;" title="BIXI_TORONTO-RGB-1024x423" src="http://steveshaw.ca/wordpress/wp-content/uploads/2012/05/BIXI_TORONTO-RGB-1024x423-e1336334060440.jpg" alt="" width="254" height="105" /></a>On the way to see The Avengers today, my wife suggested that we rent Bixis and see if we liked them. Here&#8217;s what we liked:</p>
<ul>
<li>it was easy to pay for our bikes</li>
</ul>
<p>Here&#8217;s what we didn&#8217;t like:</p>
<ul>
<li>we couldn&#8217;t actually get both bikes, so we ended up walking</li>
</ul>
<p>We had the convenience of paying for the bikes, plus the added exercise of walking the whole way. And since we didn&#8217;t get the bikes, we didn&#8217;t have the hassle of returning them. So I guess that&#8217;s a win?</p>
<p><span id="more-80"></span>Here&#8217;s what happened: we paid for two bikes, but the machine didn&#8217;t print out the codes for one of them when we asked for it. We only had one code. My wife called the Bixi support number, and was told that there was nothing we could but wait for five minutes, then get another code. My wife asked why there wasn&#8217;t some sort of central override, and the representative told her that she &#8220;should have been paying more attention&#8221; when renting the bikes. In other words, the fact that the machine didn&#8217;t print one of the codes was her fault.</p>
<p>We ended up not waiting for five minutes, and not bothering to get a refund. Being told by a company &#8211; that has just taken your money, plus some huge deposit for bikes we never used &#8211; that the failed delivery of services was our fault was enough interaction with the company for one day. For one lifetime, in fact.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2012/05/06/and-then-the-bixi-rep-implied-my-wife-was-an-idiot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring testing framework: how to load the application context from the file system</title>
		<link>http://steveshaw.ca/2011/11/18/spring-testing-framework-how-to-load-the-application-context-from-the-file-system/</link>
		<comments>http://steveshaw.ca/2011/11/18/spring-testing-framework-how-to-load-the-application-context-from-the-file-system/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 18:21:14 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=76</guid>
		<description><![CDATA[While attempting to standardize the testing of a code base, I&#8217;ve been trying to enable Spring&#8217;s test-level transaction management. In a nutshell, if you run a properly configured test within Spring&#8217;s test transaction framework then then the test does not &#8230; <a href="http://steveshaw.ca/2011/11/18/spring-testing-framework-how-to-load-the-application-context-from-the-file-system/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/11/spring.png"><img src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/11/spring-300x177.png" alt="" title="spring" width="300" height="177" class="alignleft size-medium wp-image-78" /></a>While attempting to standardize the testing of a code base, I&#8217;ve been trying to enable <a href="http://static.springsource.org/spring/docs/2.5.x/reference/testing.html#testing-tx">Spring&#8217;s test-level transaction management</a>. In a nutshell, if you run a properly configured test within Spring&#8217;s test transaction framework then then the test does not actually commit anything to a database.</p>
<p>It should be as easy as annotating your test class like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@ContextConfiguration<span style="color: #009900;">&#40;</span>locations<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;application-context.xml&quot;</span><span style="color: #009900;">&#41;</span>
@TestExecutionListeners<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>TransactionalTestExecutionListener.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
@TransactionConfiguration<span style="color: #009900;">&#40;</span>transactionManager<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myTxManager&quot;</span><span style="color: #009900;">&#41;</span>
@Transactional</pre></div></div>

<p>This loads the application context from the classpath and then manipulates the transaction manager named myTxManager to roll back the database transaction when the test is complete. The problem I have is that the application context file isn&#8217;t on the classpath. To make it even more interesting, it&#8217;s stored on a different place on each developer workstation. There&#8217;s already a utility to discover the file, I just need to hook it into the context loader.</p>
<p><span id="more-76"></span><br />
After reading <a href="http://forum.springsource.org/archive/index.php/t-44020.html">this</a>, it became apparent that what I wanted was to write my own context loader. All that&#8217;s needed is to change the location(s) to include the file path (plus a file: prefix) so that the resource loader can locate the files.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyContextLoader <span style="color: #000000; font-weight: bold;">extends</span> GenericXmlContextLoader <span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> modifyLocations<span style="color: #009900;">&#40;</span>Class<span style="color: #339933;">&lt;?&gt;</span> clazz, <span style="color: #003399;">String</span>... <span style="color: #006633;">locations</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> modifiedLocations <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span>locations.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> locations.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            modifiedLocations<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;file:&quot;</span> 
                <span style="color: #339933;">+</span> FileLocator.<span style="color: #006633;">getApplicationContextDir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
                <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">+</span> locations<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> modifiedLocations<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And then I change one line in the test class annotation:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@ContextConfiguration<span style="color: #009900;">&#40;</span>locations<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;application-context.xml&quot;</span>, loader<span style="color: #339933;">=</span>MyContextLoader.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Now the test will look in the appropriate location on each developer&#8217;s machine and load the application context file properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/11/18/spring-testing-framework-how-to-load-the-application-context-from-the-file-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On leaving a job after 11 years</title>
		<link>http://steveshaw.ca/2011/11/08/on-leaving-a-job-after-11-years/</link>
		<comments>http://steveshaw.ca/2011/11/08/on-leaving-a-job-after-11-years/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 01:12:25 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Admin]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=73</guid>
		<description><![CDATA[After nearly eleven years, I recently left Intelliware and have accepted a new position at Autodesk. It&#8217;s a weird thing in today&#8217;s environment to work anywhere for as long as that, and it&#8217;s doubly weird to leave after that time. &#8230; <a href="http://steveshaw.ca/2011/11/08/on-leaving-a-job-after-11-years/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/11/DSC_0905.jpg"><img class="alignright size-medium wp-image-74" title="DSC_0905" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/11/DSC_0905-300x237.jpg" alt="" width="300" height="237" /></a>After nearly eleven years, I recently left <a href="http://intelliware.ca">Intelliware</a> and have accepted a new position at <a href="http://autodesk.ca">Autodesk</a>. It&#8217;s a weird thing in today&#8217;s environment to work anywhere for as long as that, and it&#8217;s doubly weird to leave after that time.</p>
<p>It works for me, though. I&#8217;m a good fit for the new position, and the challenge will be good for me. It&#8217;s tough to leave a small company like Intelliware, where I felt (and still feel) real kinship with the management and ownership teams. I knew my work made a difference, but it kind of feels like a big-fish-in-small-pond situation. I&#8217;d like to see what I can do in a much larger company.</p>
<p><span id="more-73"></span>What this means, though, is that my iOS development career is on hold indefinitely. The new job is another Java position, but all of my brain muscles are going to be occupied by learning a new environment, processes, and all the other stuff that comes along with a new job.</p>
<p>That being said, it&#8217;s the night before my first day and I&#8217;m not nervous at all. That&#8217;s got to be a good sign, right? I think all my project work for the last seventeen years or so allows me to treat this gig as another client, at least in terms of ramp-up. I&#8217;m comfortable with going into unfamiliar situations and figuring out what I&#8217;m supposed to be doing in a very short period of time. Even this cold I&#8217;m fighting isn&#8217;t putting a damper on it.</p>
<p>It&#8217;s likely that the technical focus of this blog (that, again, no one reads) will shift and focus more on those parts of the new job experience that I am able to share. I won&#8217;t be blogging any more details than I did in my Intelliware blog, but since I don&#8217;t have an outlet at work (I think&#8230;), I may be writing about Java technology a little bit here.</p>
<p>Finally, the picture at the top of the post is one that I took last week in Hawaii. The Big Island has beaches where these big damn turtles just swim up and sun themselves. It&#8217;s pretty great.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/11/08/on-leaving-a-job-after-11-years/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Does Avis overbook?</title>
		<link>http://steveshaw.ca/2011/10/16/doe-avis-overbook/</link>
		<comments>http://steveshaw.ca/2011/10/16/doe-avis-overbook/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 19:55:57 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Bitching]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=70</guid>
		<description><![CDATA[It appears that the answer is &#8220;yes&#8221;. Here&#8217;s my story. In order for my wife and I to make it my family&#8217;s Thanksgiving dinner, we had rented a car for Saturday, October 8, 2011. We showed up at the rental &#8230; <a href="http://steveshaw.ca/2011/10/16/doe-avis-overbook/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/10/avis_logo1.jpg"><img class="alignleft size-medium wp-image-72" title="avis_logo1" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/10/avis_logo1-300x101.jpg" alt="" width="300" height="101" /></a>It appears that the answer is &#8220;yes&#8221;.</p>
<p>Here&#8217;s my story. In order for my wife and I to make it my family&#8217;s Thanksgiving dinner, we had rented a car for Saturday, October 8, 2011. We showed up at the rental location (for reference, it was the Bloor St E location, in the Hudson Bay building concourse) at the appointed time, and arrived to chaotic scene. There was a dude at the front of the line yelling at a couple of workers and a huge lineup of people that stretched out of the office. It quickly became apparent that there weren&#8217;t any cars, there hadn&#8217;t been any cars for quite some time, and that there weren&#8217;t going to be any cars anytime soon.</p>
<p><span id="more-70"></span>When we got to the front of the line, we took it easy on a nice man named Owen, who seemed to be running the shop that day. He explained that there weren&#8217;t cars for anyone, that he was very sorry, and that we should write a letter to head office with any complaints. It seems that screwups like that are not taken seriously by Avis unless customers complain.</p>
<p>Unfortunately, since it was noon when we attempted to pick up the car, and Avis had been turning people away all day, there were no other cars to be had. We tried the Hertz across the hall, the Discount down the street, and Zipcar. None of them had anything &#8211; although Hertz and Discount had cars at the beginning of the day, they we all snapped up by people that got fucked over by Avis. Nothing else was available in the city.</p>
<p>So we weren&#8217;t able to drive to my family&#8217;s home to celebrate Thanksgiving. Thanks, Avis! Thanks a bunch.</p>
<p>All of our attempts to find out what happened have been rebuffed. Michaela assumed right off the bat that they&#8217;d overbooked. I was trying to be more charitable, assuming it was some sort of scheduling snafu and that cars were just stuck at the airport or whatever and that they&#8217;d show up in a couple of hours. I was, of course, wrong &#8211; it was 4:30 by the time we were called to be told that there wasn&#8217;t going to be a car.</p>
<p>The next day, Michaela submitted a complaint via the Avis website and got a fairly prompt reply. The reply was basically a canned response that ignored the content of the complaint completely. Michaela primarily asked for an explanation of the incident &#8211; basically, what happened and what was being done to ensure it would never happen again? That question was completely ignored and instead they offered us a $75 credit.</p>
<p>Here&#8217;s the problem: we don&#8217;t want a $75 dollar credit. We want to have cars available at those times that we&#8217;ve reserved them. That&#8217;s all that a car rental company has to do, and Avis fucked it up royally this time. And it&#8217;s not only us that got screwed &#8211; it was anyone else that trusted Avis with their business on a holiday weekend.</p>
<p>There are a lot of questions that should be answered. I don&#8217;t expect to ever find out the answers, but then again I don&#8217;t plan on renting on from Avis or any related company ever again, so I guess it&#8217;s a fair trade.</p>
<ul>
<li>Does Avis overbook?</li>
<li>If not, then what happened on Thanksgiving weekend 2011 in Toronto?</li>
<li>If so, is this a practice that will continue?</li>
<li>At what point was it clear that cars would not be available? Would it not have behooved the company to contact their clients when that became clear and allow for them to make other arrangements?</li>
<li>Where was the manager of the store at the time there were ten angry customers being told that there were no cars?</li>
<li>Why are the answers to these questions such a secret?</li>
</ul>
<p>I have to point out that there were no hordes of angry customers at the Hertz or Discount locations. I&#8217;m just guessing here, but that&#8217;s likely because they don&#8217;t try to actively fuck over their customers and they had cars available for those people that reserved them.</p>
<p>My next step is a letter to the CEO of Avis that will likely get read and responded to by some flunky. I imagine they&#8217;ll up the compensation offered to us instead of answering any questions. And that&#8217;s fine, that&#8217;s their right. Just as it&#8217;s my right never to do business with them (or Budget, since they&#8217;re the same company now), and to tell everyone that I know that they should do the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/10/16/doe-avis-overbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A change of direction</title>
		<link>http://steveshaw.ca/2011/10/13/a-change-of-direction/</link>
		<comments>http://steveshaw.ca/2011/10/13/a-change-of-direction/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 23:42:11 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[The project]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=65</guid>
		<description><![CDATA[For reasons that I&#8217;m not quite at liberty to go into (even on a blog that no one reads), I&#8217;ve abandoned the idea of creating an iOS app for the time being. I&#8217;ll still use this blog to map out &#8230; <a href="http://steveshaw.ca/2011/10/13/a-change-of-direction/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/10/soave.jpg"><img class="alignright size-full wp-image-68" title="soave" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/10/soave.jpg" alt="" width="45" height="169" /></a>For reasons that I&#8217;m not quite at liberty to go into (even on a blog that no one reads), I&#8217;ve abandoned the idea of creating an iOS app for the time being. I&#8217;ll still use this blog to map out some technical stuff &#8211; there&#8217;s some JavaScript I&#8217;d really like to play with &#8211; but my Big Top-Secret Project is off the table for now.</p>
<p>So I guess there&#8217;s no reason not to describe my intended project. It was a wine review database. Here&#8217;s the use case: you read a wine review in the paper on Wednesday, but when you&#8217;re in the liquor store the next day, you can&#8217;t remember what you&#8217;re interested in buying. Boom! You simply pull out my app on your phone and sort the available reviews by date, find your review, find your wine, and get all drunkified.</p>
<p><span id="more-65"></span>The app fills a definite need &#8211; at least one that I have, and that&#8217;s enough of a reason to create it. However, there&#8217;s a back-end system that needs to be in place to effectively perform something like this &#8211; a review database. And that database needs to be primed with reviews on a continuing basis. The overhead of the maintenance is something that a content farm could handle without any trouble, but it&#8217;s an added timesink for a guy that just wants to write code for the time being.</p>
<p>The blog is going to continue, but I think more personal stuff will leak in. That will likely give me more material, and hell, I might actually start publicizing blog entries.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/10/13/a-change-of-direction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playbook: It Doesn&#8217;t &#8220;Just Work&#8221;</title>
		<link>http://steveshaw.ca/2011/09/20/playbook-it-doesnt-just-work/</link>
		<comments>http://steveshaw.ca/2011/09/20/playbook-it-doesnt-just-work/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 18:13:39 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=62</guid>
		<description><![CDATA[Against my better judgement, I bought my wife a Playbook for her birthday. She&#8217;s basically married to her BlackBerry, with me being the newcomer to the relationship. And while I&#8217;ve become an Apple fanboy over the last year, she&#8217;s equally &#8230; <a href="http://steveshaw.ca/2011/09/20/playbook-it-doesnt-just-work/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/09/playbook.jpeg"><img class="alignleft size-medium wp-image-64" title="playbook" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/09/playbook-300x152.jpg" alt="" width="300" height="152" /></a>Against my better judgement, I bought my wife a <a href="http://us.blackberry.com/playbook-tablet/">Playbook</a> for her birthday. She&#8217;s basically married to her BlackBerry, with me being the newcomer to the relationship. And while <a href="index.php?p=37">I&#8217;ve become an Apple fanboy over the last year</a>, she&#8217;s equally comitted to RIM.</p>
<p>From some experiences at work, I knew that the Playbook was a little flaky. I thought maybe that was me being over-critical of it based on the experience of developing for it &#8211; surely RIM can&#8217;t hate its users as much as<a href="http://blog.jamiemurai.com/2011/02/you-win-rim/"> it hates developers</a>. It turns out I was wrong.</p>
<p><span id="more-62"></span>Within two minutes of starting it up, while going through the mandatory license acceptance &#8211; which, for some reason, required WiFi access &#8211; the on-screen keyboard disappeared and  we weren&#8217;t able to enter my wife&#8217;s AppWorld credentials. We had to do a hard reset of the  device (hold the volume down button + the power button for a few seconds) in order to get it to a state where we could enter credentials.</p>
<p>That initial interaction was a preview of the problems to come. The screen behaved oddly, simple apps like the Kobo e-reader didn&#8217;t work at first, and the whole experience felt a  little shoddy. I can&#8217;t help but compare this to the experience I had with my iPod touch, iPad and iPhone &#8211; as everyone says, they just worked. Apple spends a lot of time and money making sure that their products deliver a good user experience, and I think RIM still has a long way to go in that regard.</p>
<p>To be fair, a lot of the problems seem to have cleared up as my wife gets used to the device. We&#8217;ll see what happens in the coming months.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/09/20/playbook-it-doesnt-just-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Still alive</title>
		<link>http://steveshaw.ca/2011/09/05/still-alive/</link>
		<comments>http://steveshaw.ca/2011/09/05/still-alive/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 20:31:23 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[The project]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=60</guid>
		<description><![CDATA[It&#8217;s now officially been over a month since I last updated. It&#8217;s a little disappointing: I&#8217;m sort of striving for weekly updates, and I&#8217;ve let the project lapse for several weeks. I&#8217;ve got the usual excuses: work has picked up, &#8230; <a href="http://steveshaw.ca/2011/09/05/still-alive/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/09/stillalive.png"><img class="alignright size-medium wp-image-61" title="stillalive" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/09/stillalive-300x240.png" alt="" width="300" height="240" /></a>It&#8217;s now officially been over a month since I last updated. It&#8217;s a little disappointing: I&#8217;m sort of striving for weekly updates, and I&#8217;ve let the project lapse for several weeks. I&#8217;ve got the usual excuses: work has picked up, summer is a difficult time to stay inside and code, and, honestly, it&#8217;s turned out to be more of a chore than I expected. Today is Labour Day and I spent it napping and hanging out with my wife when I meant to spend at least a few hours coding.</p>
<p>But I&#8217;ve been thinking about apps in the background. Specifically, I&#8217;m going to write a drinking companion app branded for <a href="http://drunks.ca">drunks.ca</a>. I&#8217;m going to use the Google Maps stuff I&#8217;ve been doing for a client at work and marry it to an iPhone app that will tell you where you can drink, how to get there, and how to get home (that is, it will provide a list of cab phone numbers for your local area). This isn&#8217;t something that I expect anyone to pay for, but I think some of my friends could get a kick out of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/09/05/still-alive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The more you know</title>
		<link>http://steveshaw.ca/2011/08/01/the-more-you-know/</link>
		<comments>http://steveshaw.ca/2011/08/01/the-more-you-know/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 21:45:49 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[The project]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=57</guid>
		<description><![CDATA[One of the problems I knew I would have with using Rails is that I don&#8217;t know a thing about Ruby or Rails. That&#8217;s the point &#8211; I wanted to learn at least the outlines of the language, and I &#8230; <a href="http://steveshaw.ca/2011/08/01/the-more-you-know/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/08/the-more-you-know.jpg"><img class="alignleft size-medium wp-image-58" title="the-more-you-know" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/08/the-more-you-know-300x197.jpg" alt="" width="300" height="197" /></a><br />
One of the problems I knew I would have with using Rails is that I don&#8217;t know a thing about Ruby or Rails. That&#8217;s the point &#8211; I wanted to learn at least the outlines of the language, and I learn best when I&#8217;ve got a project to use as an excuse to learn things. And since my method of learning this stuff has so far been randomly googling stuff as I need it, I was bound to run across different ways of doing things.</p>
<p>For example, when I wanted to create a drop-down select box, I followed these steps:</p>
<ol>
<li>create a find_all_whatever method in whatever.rb model class</li>
<li>initialize a @whatevers variable in the controller using the find_all method</li>
<li>define a select object on the form that referenced @whatevers</li>
</ol>
<p><span id="more-57"></span><br />
Turns out that this is at least partly unnecessary. I found this code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:whatever_id</span>, Whatever.<span style="color:#9900CC;">all</span>.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">name</span>, <span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>This makes use of the Ruby <a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_enumerable.html#Enumerable.collect">collect method of the Enumerable mixin</a> to return an array that can be used to populate the selection box.</p>
<p>One problem: the &#8220;whatevers&#8221; are not sorted, but instead are returned in whatever order they were entered. That&#8217;s easy enough to get around &#8211; the <a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_m_enumerable.html#Enumerable.sort">sort method of the Enumerable mixin</a> can be used. In my case, each of my model classes has a field named &#8220;name&#8221;, so something like this works:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:whatever_id</span>, Whatever.<span style="color:#9900CC;">all</span>.<span style="color:#9900CC;">sort</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>a, b<span style="color:#006600; font-weight:bold;">|</span>a.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">&lt;=&gt;</span> b.<span style="color:#9900CC;">name</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">name</span>, <span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Basically we&#8217;re defining the comparison to use for the sort in the parameters passed to the sort method. Another approach is to shorten this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:whatever_id</span>, Whatever.<span style="color:#9900CC;">all</span>.<span style="color:#9900CC;">sort</span>.<span style="color:#9900CC;">collect</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">name</span>, <span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>and <a href="http://www.skorks.com/2009/09/ruby-equality-and-object-comparison/">define a comparison</a> in the whatever.rb model class:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#006600; font-weight:bold;">&lt;=&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span>another<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">&lt;=&gt;</span> another.<span style="color:#9900CC;">name</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/08/01/the-more-you-know/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a reference to an existing entity in Rails</title>
		<link>http://steveshaw.ca/2011/07/24/adding-a-referenc-to-an-existing-entity-in-rails/</link>
		<comments>http://steveshaw.ca/2011/07/24/adding-a-referenc-to-an-existing-entity-in-rails/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 20:40:57 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[The project]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=53</guid>
		<description><![CDATA[The last time I touched this code I created an entity named Review that referenced a Publication. I&#8217;d like to modify Review to also have a Reviewer. (I&#8217;ve decided that Publication and Reviewer are for my purposes independent &#8211; a &#8230; <a href="http://steveshaw.ca/2011/07/24/adding-a-referenc-to-an-existing-entity-in-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/07/ebert.jpg"><img style="border: 1.0px solid black;" class="alignright size-full wp-image-51" title="ebert" src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/07/ebert.jpg" alt="" width="194" height="259" /></a><a href="/index.php?p=48">The last time</a> I touched this code I created an entity named Review that referenced a Publication. I&#8217;d like to modify Review to also have a Reviewer. (I&#8217;ve decided that Publication and Reviewer are for my purposes independent &#8211; a Reviewer is a person and a Publication is, well, a publication. While there can be a relationship between them (e.g., Ebert usually writes for the <em>Chicago Sun-Times</em>), that relationship doesn&#8217;t always hold for the entirety of a reviewer&#8217;s career.</p>
<p>The first thing to do is create the Reviewer entity. For now, reviewers only have a name.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rails generate scaffold Reviewer name:string
rake db:migrate</pre></div></div>

<p><span id="more-53"></span><br />
I also added a link to the reviewers page in app/views/home/index.html.erb:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;%= link_to &quot;Reviewers&quot;, reviewers_path %&gt;</pre></div></div>

<p>That&#8217;s all stuff that I&#8217;ve done before. Now I want to add a reference from Review to Reviewer, that is, a review has a reviewer. It turns out that there isn&#8217;t a auto-generated way to do this (at least not one that I could find). Instead, I followed the directions in this <a href="http://stackoverflow.com/questions/4338973/adding-a-model-reference-to-existing-rails-model">stackoverflow post</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rails generate migration AddReviewerToReview</pre></div></div>

<p>That gives me an empty database revision to work with in db/migrate. In that new class:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> AddReviewerToReview <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    add_column <span style="color:#ff3333; font-weight:bold;">:reviews</span>, <span style="color:#ff3333; font-weight:bold;">:reviewer_id</span>, :<span style="color:#CC0066; font-weight:bold;">integer</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    remove_column <span style="color:#ff3333; font-weight:bold;">:reviews</span>, <span style="color:#ff3333; font-weight:bold;">:reviewer_id</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>As well, I added &#8220;has_many :reviews&#8221; to app/models/reviewer.rb and and &#8220;belongs_to :reviewer&#8221; to app/models/review.rb.</p>
<p>After that, it&#8217;s just a matter of modifying the Reviews view and controller as I did last time. In app/views/reviews/_form.html.erb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  &lt;div class=&quot;field&quot;&gt;
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">label</span> <span style="color:#ff3333; font-weight:bold;">:reviewer</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:reviewer_id</span>, <span style="color:#0066ff; font-weight:bold;">@reviewers</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;/div&gt;</pre></div></div>

<p>And in app/controllers/reviews_controller.rb, the &#8220;new&#8221; and &#8220;edit&#8221; actions:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@reviewers</span> = Reviewer.<span style="color:#9900CC;">find_all_reviewers</span></pre></div></div>

<p>Also, of course, the find_all_reviewers method must be added to app/models/reviewer.rb.</p>
<p>It took me a couple of tries to get this right. A couple of commands that helped me when I needed to reset my workspace:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> reset <span style="color: #660033;">-hard</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> clean <span style="color: #660033;">-d</span> <span style="color: #660033;">-x</span> <span style="color: #660033;">-f</span></pre></div></div>

<p>The first resets the working copy, the second removes anything from the working copy that isn&#8217;t under git&#8217;s control.</p>
<p>As well, it was useful to be able to reset my database:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rake db:reset</pre></div></div>

<p>(Note to self: the code checked in for this blog entry has been tagged project-blog-entry-3.)</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/07/24/adding-a-referenc-to-an-existing-entity-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a second entity</title>
		<link>http://steveshaw.ca/2011/07/05/adding-a-second-entit/</link>
		<comments>http://steveshaw.ca/2011/07/05/adding-a-second-entit/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 01:22:39 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[The project]]></category>

		<guid isPermaLink="false">http://steveshaw.ca/?p=48</guid>
		<description><![CDATA[Now that I&#8217;ve got a basic app in place, I&#8217;d like to start fleshing it out. I&#8217;ve veered off from the Ruby primer and will pick stuff up from the web as I need to. Today I&#8217;d like to set &#8230; <a href="http://steveshaw.ca/2011/07/05/adding-a-second-entit/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://steveshaw.ca/wordpress/wp-content/uploads/2011/07/Screen-shot-2011-07-04-at-9.09.23-PM.png"><img src="http://steveshaw.ca/wordpress/wp-content/uploads/2011/07/Screen-shot-2011-07-04-at-9.09.23-PM.png" alt="" style="border: 1.0px solid black;" title="Drop-down" width="169" height="85" class="alignright size-full wp-image-51" /></a>Now that I&#8217;ve got a <a href="/index.php?p=43">basic app in place</a>, I&#8217;d like to start fleshing it out. I&#8217;ve veered off from the Ruby primer and will pick stuff up from the web as I need to.</p>
<p>Today I&#8217;d like to set up the Review entity. In addition to the normally-entered data fields (date, URL and full text of the review), each review belongs to a publication. I&#8217;d like to select the publication from a drop-down list.</p>
<p><span id="more-48"></span><br />
A quick Google search turned up <a href="http://bparanj.blogspot.com/2007/03/how-to-create-drop-down-boxes-in-ruby.html">this overview of setting up a drop-down in Rails</a>. There&#8217;s a lot there &#8211; I picked out the pieces that I needed.</p>
<p>First off, create the scaffold of the Review entity.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rails generate scaffold Review review_date:<span style="color: #c20cb9; font-weight: bold;">date</span> url:string full_text:text publication:references 
rake db:migrate</pre></div></div>

<p>The mapping from review to publication is handled automatically. To make Publication aware of Review we add a has_many relationship. And while we&#8217;re there, let&#8217;s define a class method to find all Publications. (Class methods are what I, as a long-term Java programmer, think of as static methods.)</p>
<p>In app/models/publication.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Publication <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  has_many <span style="color:#ff3333; font-weight:bold;">:reviews</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">find_all_publications</span>
    Publication.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;name&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">map</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#91;</span>u.<span style="color:#9900CC;">name</span>, u.<span style="color:#9900CC;">id</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span> 
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I&#8217;m not sure that this method belongs in the model definition, but that&#8217;s what the example I was following did. I&#8217;m used to separating data access from data definition. I&#8217;m also not sure about the singular vs. plural nature of naming conventions. I&#8217;ll become more familiar with best practices as I go along.</p>
<p>When the scaffold generates the Review controller, it defaults to using a text field for Publication. I&#8217;d like to change that to a drop-down. In app/views/reviews/_form.html:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  &lt;div class=&quot;field&quot;&gt;
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#9900CC;">label</span> <span style="color:#ff3333; font-weight:bold;">:publication</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;br /&gt;
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= f.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:publication_id</span>, <span style="color:#0066ff; font-weight:bold;">@publications</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;/div&gt;</pre></div></div>

<p>This replaces a text_field. Now we have to initialize the variable @publications. In app/controllers/reviews_controller, we simply add a line to initialize @publications with the results of the class method we defined above:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># GET /reviews/new</span>
  <span style="color:#008000; font-style:italic;"># GET /reviews/new.xml</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> new
    <span style="color:#0066ff; font-weight:bold;">@review</span> = Review.<span style="color:#9900CC;">new</span>
    <span style="color:#0066ff; font-weight:bold;">@publications</span> = Publication.<span style="color:#9900CC;">find_all_publications</span>
&nbsp;
    respond_to <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#008000; font-style:italic;"># new.html.erb</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">xml</span>  <span style="color:#006600; font-weight:bold;">&#123;</span> render <span style="color:#ff3333; font-weight:bold;">:xml</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@review</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>A similar line should be put in place in the edit method of the controller.</p>
<p>Add another line to app/views/home/index.html.erb:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;%= link_to &quot;Reviews&quot;, reviews_path %&gt;</pre></div></div>

<p>Start the server, add a publication or two, then try to add a review. The publication drop-down is populated as expected.</p>
<p>There is a problem once we save a review: the publication shows up in the review list as something like #. I assume that&#8217;s because the app doesn&#8217;t know how to render a Publication. For now, I simply modified app/views/reviews/index.html.erb and app/views/reviews/show.html.erb to display publication.name instead of publication.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;p&gt;
  &lt;b&gt;Publication:&lt;/b&gt;
  &lt;%= @review.publication.name %&gt;
&lt;/p&gt;</pre></div></div>

<p>That&#8217;s a solid second step. Using this sort of model, I can flesh out my entire review database over the next couple of sessions. I won&#8217;t be blogging it unless I run across something unexpected. The next step that I blog about will hopefully be the generation of a JSON representation of a review.</p>
<p>(Note to self: the code checked in for this blog entry has been tagged project-blog-entry-2.)</p>
]]></content:encoded>
			<wfw:commentRss>http://steveshaw.ca/2011/07/05/adding-a-second-entit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

