<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Mark Cornick]]></title>
  <link href="http://markcornick.com/atom.xml" rel="self"/>
  <link href="http://markcornick.com/"/>
  <updated>2012-02-22T11:46:45-05:00</updated>
  <id>http://markcornick.com/</id>
  <author>
    <name><![CDATA[Mark Cornick]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Upgrading to Rails 3]]></title>
    <link href="http://markcornick.com/blog/2012/01/14/upgrading-to-rails-3/"/>
    <updated>2012-01-14T11:43:00-05:00</updated>
    <id>http://markcornick.com/blog/2012/01/14/upgrading-to-rails-3</id>
    <content type="html"><![CDATA[<p>At <a href="http://www.teamsnap.com/">TeamSnap</a>, we&#8217;re preparing to upgrade our code base from
Rails 2 to Rails 3. To get some practice with this, I&#8217;ve been working on
updating the <a href="http://klang.org/">Klang</a> app that I maintain.</p>

<!--more-->


<p>The guys at Airbnb have <a href="http://nerds.airbnb.com/upgrading-airbnb-from-rails-23-to-rails-30">an excellent account</a> of their own
experience. All of their advice is very good. I was lucky in that I had
already done step 1 (move to Bundler) and step 2 (add the <code>rails_xss</code>
plugin) - in fact, I did <code>rails_xss</code> about two years ago, when I thought
I would get to the rest of the Rails 3 upgrade soon. That didn&#8217;t happen,
but it did mean a lot of the really hard work was done when I started
the upgrade in earnest.</p>

<p><span class='pullquote-right' data-pullquote='There were tons of deprecated features that I had to address. '>
There were tons of deprecated features that I had to address. Most
of them were no big deal. Learning <a href="http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3">the new ActionMailer API</a>
took a bit of head-wrap-around, but in the end it wasn&#8217;t a problem. The
biggest problem was that <a href="https://github.com/thoughtbot/shoulda">Shoulda</a> just failed horribly in all
of my functional tests (yes, I&#8217;m still using good old Test::Unit, not
rspec - that&#8217;s a paradigm shift for another day.) The unit tests were
fine, but the functional tests that had run perfectly under Rails 2
broke inconsistently under Rails 3. In the end, I ended up rewriting the
functional tests to not use Shoulda, and ran those tests instead. When
everything else was working, I put the Shoulda-fied tests back in, and
they worked fine. I spent a few hours de-Shoulda-fying the tests, but
I&#8217;ll chalk it up to a useful learning exercise.
</span></p>

<p>One thing that bit me was several of my &#8220;destroy&#8221; links on the admin
side simply failed to work. This was my own damn fault; I should&#8217;ve been
using form submissions to do these all along. As often happens, Stack
Overflow <a href="http://stackoverflow.com/questions/4606860/rails-3-link-to-to-destroy-not-working">pointed me in the right direction</a> and I
replaced all the <code>link_to</code>s with <code>button_to</code>s. That fixed that.</p>

<p>So at this point, I&#8217;ve got the application running on Rails 3.0, with
all of the tests passing, and it works well in development mode on
<a href="http://pow.cx/">Pow</a>. The next step will be uploading this to a new app on
<a href="http://www.heroku.com/">Heroku</a>, alongside our existing Rails 2 app, and pounding on it
for a while. But it all looks good right now.</p>

<p>Once this is done, moving to Rails 3.1 is the next step. We don&#8217;t do a
lot of JavaScript at Klang, but we&#8217;ve got some, so the asset pipeline is
likely to be our biggest challenge. And from there, who knows&#8230; maybe
we&#8217;ll all be on Rails 4 by then?</p>
]]></content>
  </entry>
  
</feed>

