<?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"
	>

<channel>
	<title>The Life Of A Radar</title>
	<atom:link href="http://frozenplague.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://frozenplague.net</link>
	<description>Life &#38; Everything Else</description>
	<pubDate>Mon, 18 Aug 2008 11:32:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Reliance</title>
		<link>http://frozenplague.net/2008/08/18/reliance/</link>
		<comments>http://frozenplague.net/2008/08/18/reliance/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 11:32:38 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=205</guid>
		<description><![CDATA[I honestly don&#8217;t know what to write here. I am disappointed in the people around me, and myself. I rely on them to do things for me and they don&#8217;t get done, and I return the favour. Not feeling like the best of people right now.
]]></description>
			<content:encoded><![CDATA[<p>I honestly don&#8217;t know what to write here. I am disappointed in the people around me, and myself. I rely on them to do things for me and they don&#8217;t get done, and I return the favour. Not feeling like the best of people right now.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/08/18/reliance/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Moving Topics</title>
		<link>http://frozenplague.net/2008/08/13/moving-topics/</link>
		<comments>http://frozenplague.net/2008/08/13/moving-topics/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 11:54:55 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=204</guid>
		<description><![CDATA[Worked out topic moving. Code can be seen here.
There was a big whinge about how hard it is, but I was just in a retarded state of mind. One good night&#8217;s sleep and explaining it to multiple people (thanks Justin Smestad and Brenton Fletcher!) clarifies so much.
]]></description>
			<content:encoded><![CDATA[<p>Worked out topic moving. Code can be seen <a href='http://github.com/Radar/rboard/commit/8872174c29284cfdab1b4eea1a88aa2d0cbdaf6b'>here</a>.</p>
<p>There was a big whinge about how hard it is, but I was just in a retarded state of mind. One good night&#8217;s sleep and explaining it to multiple people (thanks Justin Smestad and Brenton Fletcher!) clarifies so much.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/08/13/moving-topics/feed/</wfw:commentRss>
		</item>
		<item>
		<title>InLAN</title>
		<link>http://frozenplague.net/2008/08/10/inlan/</link>
		<comments>http://frozenplague.net/2008/08/10/inlan/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 03:04:05 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=203</guid>
		<description><![CDATA[Went to InLAN last night and it was great fun. Won the TF2 comp with Devastator, Insane Gazebo (aka Precious Pergola), Cadiniller and TheScream, came second in Warsow (even though Devastator was so confident that was his place) and won a door prize of about 500g worth of chocolate.
Upon driving home on The Golden Way, [...]]]></description>
			<content:encoded><![CDATA[<p>Went to InLAN last night and it was great fun. Won the TF2 comp with Devastator, Insane Gazebo (aka Precious Pergola), Cadiniller and <a href="http://blog.thescream.org">TheScream</a>, came second in Warsow (even though Devastator was so confident that was his place) and won a door prize of about 500g worth of chocolate.</p>
<p>Upon driving home <a href="http://maps.google.com/?ie=UTF8&#038;ll=-34.799374,138.685559&#038;spn=0.00548,0.011373&#038;z=17">on The Golden Way</a>, during very light showers on slippery road, a stoned pedestrian decides it an appropriate time to step out onto the road. Not only was he now ON the road, but my car was also ON the road and in the same lane. A short fight ensued between a 1-ton 70-kilometer per hour moving vehicle and a 90kg pedestrian in which the pedestrian destroyed the car&#8217;s front grill, dented the bumper and bonnet, rolled up the bonnet and proceeded to smash the bottom left hand corner of the windshield before bouncing off the car and onto the road to lay unconcious. All the while, Devastator&#8217;s screaming and I&#8217;m not too calm myself. Police arrived, ambos and fire crew too. Statements, blood alcohol readings (negative) and drug tests (negative also) were taken. Hilarity did not ensue. It was cold. It was raining. It was not fun at all. I don&#8217;t recommend doing it. Pictures of my <a href="http://www.flickr.com/photos/radarlistener/sets/72157606637175442/">now not-so-sweet ride can be found here</a>.</p>
<p>Some more information is:</p>
<ul>
<li>The police were apparently looking for a guy matching his description. I was never told why. Something about a petrol station.</li>
<li>He was unconscious after I hit him and still when I dragged him (and I&#8217;ve been told I wasn&#8217;t supposed to do that) but seemed to be regaining consciousness when he was lifted into the ambulance.</li>
<li>He probably has a collapsed lung due to the impact and possible broken ribs (yes, plural)</li>
<li>I heard over the police radio mention of marijuana in relation to the description of the guy</li>
<li>My dashboard is now loose on the right, but nothing a little glue can&#8217;t hold still</li>
<li>I&#8217;m fine, Devastator sounded a bit shaky still this afternoon</li>
<li>Thank you for your concern, especially Dad who didn&#8217;t hesitate to come out and pick me up that late at night.</li>
</ul>
<p>So, tomorrow I&#8217;m taking the day off work and taking the car to get repaired. During the time of the day that I&#8217;m not getting the car repaired I&#8217;ll probably working. On what, we&#8217;ll have to decide tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/08/10/inlan/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Job Offer Dissection</title>
		<link>http://frozenplague.net/2008/07/31/job-offer-dissection/</link>
		<comments>http://frozenplague.net/2008/07/31/job-offer-dissection/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 11:40:08 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=202</guid>
		<description><![CDATA[I used to do these when I didn&#8217;t have a job, and since then I&#8217;ve been looking a lot less (read: not at all) for a new job. This, however, was accidentally clicked on in Apple Mail and I was tempted to dissect yet another one.

From: ryanbrogan@gmail.com

This is what made me cringe the most. If [...]]]></description>
			<content:encoded><![CDATA[<p>I used to do these when I didn&#8217;t have a job, and since then I&#8217;ve been looking a lot less (read: not at all) for a new job. This, however, was accidentally clicked on in Apple Mail and I was tempted to dissect yet another one.</p>
<div class='quote'>
From: ryanbrogan@gmail.com
</div>
<p>This is what made me cringe the most. If you&#8217;re a recruiter sending out recruitment emails, why do it from a gmail address? Why not use your own?</p>
<div class='quote'>
One of my top clients and an incredible place to work&#8230;
</div>
<p>Who? It helps to list names. Names attract people. If I told you I was going to buy you a beer you&#8217;d get all excited. Then I would reveal it would be a Fosters, and you wouldn&#8217;t be so excited. </p>
<div class='quote'>
secure two developers for staff positions paying 75-95k.
</div>
<p>With / without tax? Numbers are great, but more information is definitely needed here.</p>
<div class='quote'>
Email me @ ryan [at] magnetagency.net
</div>
<p>Ah! There it is!</p>
<div class='quote'> or ryanbrogan [at] gmail.com</div>
<p>No really?</p>
<div class='quote'>
1000.00 referral fee if someone you refer gets the position.
</div>
<p>Rupees? Zimbabwean Dollars? Kroner? Helps to specify a currency&#8230; but I guess American is inferred. Also, &#8220;fee&#8221;? Do we owe you money if we refer our friends to you?</p>
<div class='quote'>
  We know you&#8217;d send your pals for free, but that&#8217;s how we roll <img src='http://frozenplague.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</div>
<p>Ah, a smiley face. It makes me feel all warm and fuzzy. Also, respect goes out to the use of non-professional language here, makes it feel much better.</p>
<div class='quote'>We have an aggressive product list comprised of social, personalization, user-generated, and content publishing features planned for the site
</div>
<p>&#8220;Aggressive product list&#8221;? What are we talking here? A few robberies with a weapon? Rape? Murder? Genocidal maniac?</p>
<div class='quote'>
 and we&#8217;re looking for a self-motivated developer to join the team.
</div>
<p>The team should motivate the developer, but it does help to be self-motivated too. Each member of the team should feed off each other&#8217;s energy.</p>
<div class='quote'>
 If you&#8217;re interested in working in a fast-paced,
</div>
<p>Running makes me sweaty. How fast are we talking?</p>
<div class='quote'> energetic environment </div>
<p>Pepsi Max and a proper sleep cycle gives me all the energy I need</p>
<div class='quote'> come work for us. </div>
<p>Rather not, I hear the commute from here to there is about 22 hours!</p>
<div class='quote'>
Core Requirements:
</div>
<p>As compared to the other kind of requirements?</p>
<div class='quote'>
* You&#8217;re passionate about the craft of software engineering and love<br />
building cool Web applications
</div>
<p>So, say, an aspiring Trolley Pusher wouldn&#8217;t be the right kind of person for this job then?</p>
<div class='quote'>
* You&#8217;re familiar with Test/Behavior Driven Development and agile<br />
software development
</div>
<p>We spent long nights together in an orgy of code. There were files flying all over the place! A few commits took place, but nothing serious.</p>
<div class='quote'>
* You have production Ruby on Rail experience
</div>
<p>Ruby&#8217;s going monorail now, huh?</p>
<div class='quote'>including deployment</div>
<p>Inferred from last statement</p>
<div class='quote'>with Mongrel</div>
<p>ditto</p>
<div class='quote'>
* You&#8217;re comfortable with semantic XHTML and CSS (not necessarily design)
</div>
<p>Uh oh, -1 point for chucking in &#8220;semantic&#8221; in there. Big words make people sad. &#8220;Well-structured&#8221; is what I would put there.</p>
<div class='quote'>
* You&#8217;re familiar with Javascript and AJAX
</div>
<p>I have nothing witty to say about this.</p>
<div class='quote'>
* Ongoing application development
</div>
<p>Well, given that the position seems to be a Software Engineer-like position, this is pretty much a given. All application development is &#8220;ongoing&#8221;</p>
<div class='quote'>
* Production support and ticket management
</div>
<p>Ah, so the position is now more of a Software Engineer meet Tech Support meet Project Manager position now? Cool. Probably a bit overwhelming for one person (we have this in three separate roles @ <a href='http://www.netfox.com'>NetFox</a>)</p>
<div class='quote'>
* Deployment management
</div>
<p>Easy enough with Capistrano, which most Ruby on Rails developers worth their salt should know.</p>
<p>Overall, a fairly good job advertisement. Still struggling to come up with a reason for posting from Gmail, but I&#8217;m sure there&#8217;s a fairly good one behind it. Thanks for not using buzzwords (apart from the iffy &#8220;semantic&#8221;)! It takes me so long to pick them all out and decipher them&#8230; I once saw &#8220;increases business continuity&#8221; <a href='http://websense.com'>on a website</a> and I&#8217;m still trying to figure out what it means.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/31/job-offer-dissection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stop Being So Self-Centered!</title>
		<link>http://frozenplague.net/2008/07/29/stop-being-so-self-centered/</link>
		<comments>http://frozenplague.net/2008/07/29/stop-being-so-self-centered/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 11:23:41 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=201</guid>
		<description><![CDATA[I&#8217;ve seen so many examples of people being self-centered in their code, always calling their methods on self when they don&#8217;t need to!
self is a handy reference to the current object (or class) depending on how the method is defined. In a class that inherits from ActiveRecord for example, calling self before defining a method [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen so many examples of people being self-centered in their code, always calling their methods on <span class='term'>self</span> when they don&#8217;t need to!</p>
<p>self is a handy reference to the current object (or class) depending on how the method is defined. In a class that inherits from ActiveRecord for example, calling self before defining a method will define that method on that class, rather than the objects of that class. Once inside of the method, you are free to go about as you will; Ruby will know what you mean when you call other methods inside that method.</p>
<p>A prime example would be this self-centered piece of code:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">class</span> Forum &lt; <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::Base</span>
  acts_as_tree
&nbsp;
  <span style="color:#009fcd; font-weight:bold;">def</span> <span style="color:#0092bc; font-weight:bold;">to_s</span>
    <span style="color:#00c6ff; font-weight:bold;">self</span>.<span style="color:#d8f6ff;">title</span>
  <span style="color:#009fcd; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#009fcd; font-weight:bold;">def</span> <span style="color:#00c6ff; font-weight:bold;">self</span>.<span style="color:#d8f6ff;">find_all_without_parent</span>
    <span style="color:#00c6ff; font-weight:bold;">self</span>.<span style="color:#d8f6ff;">find_all_by_parent_id</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#00c6ff; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#009fcd; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#009fcd; font-weight:bold;">def</span> root
    <span style="color:#00c6ff; font-weight:bold;">self</span>.<span style="color:#d8f6ff;">parent</span>.<span style="color:#00c6ff; font-weight:bold;">nil</span>? ? <span style="color:#00c6ff; font-weight:bold;">self</span> : <span style="color:#00c6ff; font-weight:bold;">self</span>.<span style="color:#d8f6ff;">parent</span>
  <span style="color:#009fcd; font-weight:bold;">end</span>
&nbsp;
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>These are a few methods with both good and bad examples of using self. </p>
<p>We&#8217;ll start with <span class='term'>#to_s</span>. This method is defined by typing <span class='term'>def to_s</span>, which tells ruby we want to define a method called &#8220;to_s&#8221; on all objects of the Forum class. Inside the method however, we have a bad-case of self-centering, by calling self where it&#8217;s not needed. Ruby already knows that we&#8217;re operating with an object derived from the forum class, and calling self will only return the same object! So why do we do it here? We can remove the superfluous self call, and the method will still work.</p>
<p>Our next method is <span class='term'>self.find_all_without_parent</span>. The <span class='term'>self.</span> prefix to the method tells Ruby that we want to define this method on the Forum class itself, rather than a derived object from the class. Inside the method again we have a bad case of self-centering! Ruby already knows we&#8217;re operating with the Forum class, and calling self will only return the Forum class once more. Again we can remove the superfluous self call and the method will still work.</p>
<p>In both of these examples, you could&#8217;ve called self on self and then the method multiple times: <span class='term'>self.self.title</span> or even <span class='term'>self.self.self.self.self.title</span>, but that&#8217;s just going a bit overboard!</p>
<p>In the last method is two incorrect usages of self, and one correct use of self. The method is <span class='term'>#root</span>. The method defines a one-lined if statement by calling a method (<span class='term'>self.parent.nil?</span>) which will return either true or false. The next character is a space followed by a ?, which indicates to ruby anything after this is what we want executed when <span class='term'>self.parent.nil?</span> returns true. Here we just call <span class='term'>self</span>, and this is the good use of self. The <span class='term'>#root</span> method is attempting to find the root element for the tree heirachy of the forums, if the forum object we&#8217;re calling root does not have a parent, we want it to return itself as it is the highest level of the forum structure. The next character in the code is a colon (:), which tells Ruby what we want to do if <span class='term'>self.parent.nil?</span> returns false. Here we&#8217;ve called <span class='term'>self.parent</span>, which again is a superflous call to the self object. We only need to call parent because Ruby already knows which context we are referring to! The final superfluous self call is the <span class='term'>self.parent.nil?</span> from where our one-lined if statement originated.</p>
<p>I hope you&#8217;ve enjoyed this little tidbit, and please stop being so self-centered.</p>
<p>UPDATE: <a href='http://luckysneaks.com/blog'>RSL</a> has posted an easier way than <span class='term'>parent.nil? ? self : parent</span> as the first comment. The code is now simply:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> root
  parent || <span style="color:#00c6ff; font-weight:bold;">self</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>UPDATE #2: The root method was still broken as I realised this morning as I tampered with the tests. The method is supposed to get the highest forum in a string of forums. This works perfectly for 2-level-deep forums, but not for 3-level-deep. The third-level element would&#8217;ve returned the second-level element rather than the first. The revised code is now:</p>

<div class="wp_syntax"><div class="code"><pre class="rails">  <span style="color:#009fcd; font-weight:bold;">def</span> root
    parent.<span style="color:#00c6ff; font-weight:bold;">nil</span>? ? <span style="color:#00c6ff; font-weight:bold;">self</span> : <span style="color:#006600; font-weight:bold;">&#40;</span>parent.<span style="color:#d8f6ff;">root</span> == parent ? parent : parent.<span style="color:#d8f6ff;">root</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/29/stop-being-so-self-centered/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rescue Correctly!</title>
		<link>http://frozenplague.net/2008/07/28/rescue-correctly/</link>
		<comments>http://frozenplague.net/2008/07/28/rescue-correctly/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 12:37:47 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=200</guid>
		<description><![CDATA[Too many times I&#8217;ve seen people being over-zealous in rescuing their exceptions. They try doing something like this:

def show
  @forum = Forum.find&#40;params&#91;:id&#93;&#41;
  rescue Exception
   flash&#91;:notice&#93; = 'The forum you were looking for does not exist'
end

Which will work when it can&#8217;t find a forum, and also when you have a typo. Exception [...]]]></description>
			<content:encoded><![CDATA[<p>Too many times I&#8217;ve seen people being over-zealous in rescuing their exceptions. They try doing something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> <span style="color:#0092bc; font-weight:bold;">show</span>
  <span style="color:#0066ff; font-weight:bold;">@forum</span> = Forum.<span style="color:#d8f6ff;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>
   <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'The forum you were looking for does not exist'</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>Which will work when it can&#8217;t find a forum, and also when you have a typo. Exception the ancestor class of all other exceptions, and so every exception will trigger this rescue. Try making the code look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> <span style="color:#0092bc; font-weight:bold;">show</span>
  <span style="color:#0066ff; font-weight:bold;">@forum</span> = Forum.<span style="color:#d8f6ff;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>
    <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'The forum you were looking for does not exist'</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>and you&#8217;ll wonder why a forum is telling you it doesn&#8217;t exist when it obviously does! The easiest way to fix this is to rescue correctly. By rescuing correctly, you prevent hours of potential headaches and your code becomes clearer to what it&#8217;s doing. In this example, when a forum object can&#8217;t be found it will raise the <span class="term">ActiveRecord::RecordNotFound</span> exception, so this is what you should rescue.</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> <span style="color:#0092bc; font-weight:bold;">show</span>
  <span style="color:#0066ff; font-weight:bold;">@forum</span> = Forum.<span style="color:#d8f6ff;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::RecordNotFound</span>
    <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'The forum you were looking for does not exist'</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>Another situation is when you&#8217;re using <span class="term">#save!</span>. This &#8220;destructive&#8221; version of <span class="term">#save</span> will raise an <span class="term">ActiveRecord::RecordInvalid</span> or <span class="term">ActiveRecord::RecordNotSaved</span>, depending on the kind of validations you have on your model. I use it here in this example:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@topic</span> = <span style="color:#0066ff; font-weight:bold;">@forum</span>.<span style="color:#d8f6ff;">topics</span>.<span style="color:#d8f6ff;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:topic</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span> = <span style="color:#0066ff; font-weight:bold;">@topic</span>.<span style="color:#d8f6ff;">posts</span>.<span style="color:#d8f6ff;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0066ff; font-weight:bold;">@topic</span>.<span style="color:#0092bc; font-weight:bold;">save</span>!
  <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'Topic has been successfully created'</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::RecordNotSaved</span>, <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::RecordInvalid</span>
    <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'Topic could not be created'</span>
  <span style="color:#009fcd; font-weight:bold;">ensure</span>
    <span style="color:#0092bc; font-weight:bold;">redirect_to</span> forum_topics_path<span style="color:#006600; font-weight:bold;">&#40;</span>@forum<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>I&#8217;ve actually specified two arguments to the rescue method here, the first is <span class="term">ActiveRecord::RecordNotSaved</span>, and the next is <span class="term">ActiveRecord::RecordInvalid</span>. The rescue method uses the splat operator (*), so it can take as many arguments as you can throw at it. I&#8217;ve also used another method here <span class="term">ensure</span>. No matter how many exceptions get thrown, the code after the ensure statement will always be ran.</p>
<p>The final thing I would like to cover is rescuing two exceptions, but doing two different things.</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@topic</span> = <span style="color:#0066ff; font-weight:bold;">@forum</span>.<span style="color:#d8f6ff;">topics</span>.<span style="color:#d8f6ff;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:topic</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0066ff; font-weight:bold;">@post</span> = <span style="color:#0066ff; font-weight:bold;">@topic</span>.<span style="color:#d8f6ff;">posts</span>.<span style="color:#d8f6ff;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0066ff; font-weight:bold;">@topic</span>.<span style="color:#0092bc; font-weight:bold;">save</span>!
  <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'Topic has been successfully created'</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::RecordNotSaved</span>
    <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'Topic could not be created, the record could not be saved'</span>
  <span style="color:#009fcd; font-weight:bold;">rescue</span> <span style="color:#8aa6c1; font-weight:bold;">ActiveRecord::RecordInvalid</span>
    <span style="color:#0092bc; font-weight:bold;">flash</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#67ddff; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#70b4c8;">'Topic could not be created, the record is invalid'</span>
  <span style="color:#009fcd; font-weight:bold;">ensure</span>
    <span style="color:#0092bc; font-weight:bold;">redirect_to</span> forum_topics_path<span style="color:#006600; font-weight:bold;">&#40;</span>@forum<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/28/rescue-correctly/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What A Weekend!</title>
		<link>http://frozenplague.net/2008/07/25/what-a-weekend/</link>
		<comments>http://frozenplague.net/2008/07/25/what-a-weekend/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 11:45:44 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=199</guid>
		<description><![CDATA[And it hasn&#8217;t even begun!
Here I sit on a Friday night, on my bed with two quilts over the lower-half of my body. Sitting by the open window (yes, open. Even though it&#8217;s winter and 7.7 celcius outside) on my bed with my laptop on top of the quilts. My mum&#8217;s boyfriend&#8217;s son sits on [...]]]></description>
			<content:encoded><![CDATA[<p>And it hasn&#8217;t even begun!</p>
<p>Here I sit on a Friday night, on my bed with two quilts over the lower-half of my body. Sitting by the open window (yes, open. Even though it&#8217;s winter and 7.7 celcius outside) on my bed with my laptop on top of the quilts. My mum&#8217;s boyfriend&#8217;s son sits on the only chair in the room, using UbërComputer and playing Spore Creature Creator, creating a dinosaur like creature. I feel relaxed, probably due to me getting off work a bit earlier than usual because the internet was balls (dialup had better ping times), and I know that there&#8217;s going to be a lot of stuff to do on the weekend.</p>
<p>Tomorrow I&#8217;m going to be attending <a href='http://avcon.org.au'>AVCon</a>, not because I like dressing up in a Sailor Moon costume (not that I&#8217;m going to of course), I just want to see what all the fuss is about. Two of my friends (Brenton and James) have both recommended in one way or another that I go, so I&#8217;m going. Hopefully I&#8217;ll enjoy myself, but it is an <b>anime</b> andvideogames conference, and I&#8217;m not all that in to anime&#8230; </p>
<p>I&#8217;ve been tasked (is this the correct word?) to host Railscamp #4! I have an idea for a venue and I&#8217;m going to check it out on Sunday. Hopefully if all goes according to plan there should be a formal announcement soonish. Price and what not is not worked out yet, but I have a good idea and I&#8217;m not going to tell you! I&#8217;ll have a better idea Sunday night, if I can be bothered blogging about it.</p>
<p>See you on the other side!</p>
<p>EDIT: I didn&#8217;t go to AvCon (thanks for answering my calls James!), instead I scoped out the venue for Railscamp #4, went cruising with Devastator in the epic quest for computer parts and generally lazed about like all decent people [should] do on a weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/25/what-a-weekend/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Faking It</title>
		<link>http://frozenplague.net/2008/07/14/faking-it/</link>
		<comments>http://frozenplague.net/2008/07/14/faking-it/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 06:20:08 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[domains]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[rspec]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=198</guid>
		<description><![CDATA[Today I was doing the one thing I truly, truly love doing and that&#8217;s complaining about writing RSpec tests. I came across a doozy of a problem involving RSpec testing and faking subdomains. Here&#8217;s a stripped down version of what I did:

def login_as&#40;user&#41;
  session&#91;&#34;user&#34;&#93; = users&#40;user&#41;.id
  request.host = User.find&#40;session&#91;&#34;user&#34;&#93;&#41;.company.domain + &#34;.example.com&#34;
end

Just pop that [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was doing the one thing I truly, truly love doing and that&#8217;s complaining about writing RSpec tests. I came across a doozy of a problem involving RSpec testing and faking subdomains. Here&#8217;s a stripped down version of what I did:</p>

<div class="wp_syntax"><div class="code"><pre class="rails"><span style="color:#009fcd; font-weight:bold;">def</span> login_as<span style="color:#006600; font-weight:bold;">&#40;</span>user<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0092bc; font-weight:bold;">session</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#70b4c8;">&quot;user&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = users<span style="color:#006600; font-weight:bold;">&#40;</span>user<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#d8f6ff;">id</span>
  request.<span style="color:#d8f6ff;">host</span> = User.<span style="color:#d8f6ff;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0092bc; font-weight:bold;">session</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#70b4c8;">&quot;user&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#d8f6ff;">company</span>.<span style="color:#d8f6ff;">domain</span> + <span style="color:#70b4c8;">&quot;.example.com&quot;</span>
<span style="color:#009fcd; font-weight:bold;">end</span></pre></div></div>

<p>Just pop that into your <em>spec/spec_helper.rb</em> and then you can use <span class='term'>login_as(:user)</span> which will find the fixture with the name of &#8220;user&#8221; and then go from there to setting your faked host as being from, for example, blah.example.com.</p>
<p>Pretty simple, shame Google didn&#8217;t turn up any relevant results without me having to dig deeper than usual.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/14/faking-it/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Empty Wallet Treatment</title>
		<link>http://frozenplague.net/2008/07/06/empty-wallet-treatment/</link>
		<comments>http://frozenplague.net/2008/07/06/empty-wallet-treatment/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 05:16:10 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=196</guid>
		<description><![CDATA[Thanks to the guys at NetFox (Yuji or Adam) for the name for this post.
Tomorrow I go to the dentist to have empty wallet (read: root canal) treatment (hereafter referred to as EWT). My tooth that broke at Railscamp has a serious bout of decay in it no thanks to me not caring for my [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to the guys at NetFox (Yuji or Adam) for the name for this post.</p>
<p>Tomorrow I go to the dentist to have empty wallet (read: root canal) treatment (hereafter referred to as EWT). My tooth that broke at Railscamp has a serious bout of decay in it no thanks to me not caring for my teeth as I really should have, for quite too long. Consider this a warning to all the readers of this blog to look after your teeth. It&#8217;s going to cost me a fair bit (thankfully I save money, rather than spend), and thanks to a complete lack of Dental insurance I&#8217;ll be paying through the nose (or is that the mouth?). I am not in any way looking foward to the needles (notice the plural!) that are going to be going into my gum tomorrow morning. The best part is that a client is coming in tomorrow at 10:30 and I&#8217;m one of the people working on their project, so I&#8217;ll be [attempting to] speak with them. Perhaps I could type and get the text-to-speech voice on the MBP to read it out, or something.</p>
<p>Look after your teeth, please. You are not invincible, and neither am I.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/07/06/empty-wallet-treatment/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RailsCamp &#8216;08 (#1?)</title>
		<link>http://frozenplague.net/2008/06/28/railscamp-08-1/</link>
		<comments>http://frozenplague.net/2008/06/28/railscamp-08-1/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 03:38:30 +0000</pubDate>
		<dc:creator>Radar</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://frozenplague.net/?p=195</guid>
		<description><![CDATA[I had an enjoyable weekend last weekend at Railscamp, and I had this whole 3-page summary written up for you readers but I&#8217;d figured I&#8217;d spare you that lengthy document (for now, ahahaha) . These are the things you need to know:
1. It was held at Kariong (I kept calling it Kai-rong), about 6km from [...]]]></description>
			<content:encoded><![CDATA[<p>I had an enjoyable weekend last weekend at Railscamp, and I had this whole 3-page summary written up for you readers but I&#8217;d figured I&#8217;d spare you that lengthy document (for now, ahahaha) . These are the things you need to know:</p>
<p>1. It was held at Kariong (I kept calling it Kai-rong), about 6km from Gosford which itself is 1 hour and 30 minutes by train from Sydney. Scenic country-side, yada yada.<br />
2. I am in love with Sydney trains. Flippable seats and no noisy engines.<br />
3. The venue (one main hall, one &#8220;cafeteria&#8221; hall and two separate-but-joined domitories) was exceptional. We ran everything off a number of power points that you could count on one hand.<br />
4. The people were exceptional. The talks were exceptional. Nothing beat Pat Allen&#8217;s talk (the very last one at Railscamp 2.0), and nothing will ever.<br />
5. Yes Guitar Hero was played. Two <strong>and </strong>Three. Yes, I won. Yes, I&#8217;m a sore winner.<br />
6. I also coded. Gitjour became a little weekend project and it was fun working on that with Lachlan Hardy, Tim Lucas, Dr. Nic &amp; Others.<br />
7. Other applications included the ever-awesome Duke (Upload, Vote, Boogie), Swore-DS, and Pete Yandell&#8217;s proposal to create an application to track species in the wild.<br />
8. Dr. Nic was obsessed with Cherry Pie. When he wasn&#8217;t playing it on Guitar Hero 2, he was humming/singing it.<br />
9. The beds were creaky. Earplugs were my saviour.<br />
10. Lachie had a machine that made him sound like Darth Vader whilst he slept. Very chilling. Earplugs helped here too.<br />
11. There was a waterfall. We walked behind it. Then we bashed through the bush to camp.<br />
12. Risked life / possible broken bones to climb a large rock face. using nothing but what nature provided. All this whilst trying to stop my camera from bashing against it. Then walked back to &#8220;camp&#8221;, only come out 500m away at the office. Stupid GPS!<br />
13. Went away feeling fantastic.</p>
<p>There was talk of possibly another Railscamp by the end of the year, or another one this time next year. I&#8217;m looking very much forward to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://frozenplague.net/2008/06/28/railscamp-08-1/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
