Wolfmans Howlings

A programmers Blog about Programming solutions and a few other issues

Upgrading a Rails 3 app to the latest Rails 8.x

Posted by Jim Morris on 2026-01-20 17:37:59 +0000

I wrote the blog engine this blog is hosted on in 2009, that is 23 years ago as I write this.

It was running a very old version of Ruby (1.8 as I recall) running on a very old version of Ubuntu server, and was ported to Rails3 from merb. It ran all that time, but finally started to show its age (as we all do!).

I wanted to allow HTTPS access to my websites, but the version of Ubuntu and Apache were so old I couldn't use any modern tool (like getssl or certbot), and it was proving very hard if not impossible to do.

So I fired up a new slicehost server with the latest Ubuntu they offered, and I was able to get a SSL certificate and get Apache to serve HTTPS, using certbot, which basically does it all for you, that was the easy part.

Now how to migrate the sites I had on the old server to the new server? There was no way the old ruby and rails would run on this new instance (at least not without some real headaches and security risks).

The easiest one was my Home page (www.wolfman.com), I just used a command line tool that basically scraped the HTML and gave me a static site that I was able to copy into /var/www/html and away it went, https://wolfman.com/ worked. This is OK as I have not updated that site in many years and have no plans to do so anytime soon. It was running Radiant but again a very old version and I didn't fancy trying to upgrade it presuming that it is even still available.

I did want to start blogging again (hence this post), and as you may be able to see the last real blog post was in 2018 and the one before that in 2012, so it had been a while.

So I bit the bullet and just updated the Gemfile to allow the latest of everything to upgrade, that meant rails went to 8.1, and all the gems upgraded too, at least the ones that still existed. Of course the site did not run as so much has changed in 23 years! rails went from v3 to v8 and things like sequel went through as many changes. Most of these changes were not allowing backward compatibility, and the helpful deprecated warnings you would usually get when upgrading from one version to the next had long gone and the deprecations had long been removed. To make things worse RSpec which I had written all my unit tests in had also upgraded to a version which bears little resemblance to the one I used. So much for being able to use specs to test if the upgrade went well.

I decided to keep the gemfile as it was as I didn't really want a lot of the new things rails8 has added, so it only got the bare minimum I needed.

As it turned out it was easier to upgrade my rails code (models, views, controllers etc) than it was to upgrade my tests, which eventually I got to work and pass, but the changes to RSpec made that much harder than getting the main rails app to upgrade.

Ruby itself has updated from v1.8 to v3.48 however nearly all the Ruby code still worked, very few if any deprecations or removals (way to go Ruby Devs!!) The only thing I think I had to change was I was using base64 which was no longer builtin or had changed, so I just used the base64 gem and had to make a minor change to the code.

Rails8 for the things I used (Not using ActiveRecord but Sequel instead) mostly worked, there were a few breaking changes but nothing serious. (I'll try to diff and see what actually needed to change but as I decided to start from a copy rather than use git it is hard to see what I had to change).

The RSpecs are a different story. Most of the specs needed to be changed, webrat no longer works and I had to switch to capybara and factory girl had changed to factory bot and also the API was significantly different.

Sequel had a few breaking changes but nothing too hard to fix, and luckily HAML hadn't changed at all.

Of course Redis was no longer available so I will switch to memcached but that was optional anyway.

The cells gem had almost completely changed and had to be mostly rewritten, it was now cells-rails and cells-haml, and completely different. I still can't get the cells specs to pass as there appears to be changes (or bugs) in the way it interacts with the rails routes now.

One other change that has me flumoxed as I can not find it mentioned anywhere is that YAML used to allow text as is after the --- | but now it requires there be a space at the start of every line following the |, this is in the spec but I am not sure when the various YAML parsers changed it. As I edit my blog posts in sublimetext using the Markdown Extended plugin this is annoying as that space stop the markdown syntax marking from working so I need to unindent, edit, then reindent all the body of the text by one space.

At one point I was contemplating rewriting the blog in Go! but that would be a huge undertaking and I have a few other Go projects to do and now this works in rails I'll probably not do that.

Posted in Rails  |  Tags rails,upgrade  |  no comments

Comments

(leave email »)