Ask A Question

Notifications

You’re not receiving notifications from this thread.

Updating Rails Applications across Rails versions?

Andrea Fomera asked in Rails

Question, how do I go about handling the update process for my Rails apps?

Example: I setup many apps with Rails 4.0.0 and currently 4.2.0 is out. What's the update process look like? I tried to just update the Gemfile and bundle install but it seemed to mess things up.

Thank goodness for git backups. I had half a brain to do it in a new branch :) I think it'd be extremely handy if there was a resource new devs could look back on and use to help update apps.

(I found out I have to update my app because I need to use render plain: and I don't think that's in Rails 4.0.0)

Reply

This definitely deserves a screencast. I should have recorded one when I upgraded One Month's site to 4.2.

My approach to this is to update your app and configs with the changes you get at http://railsdiff.com. Then I run bundle install, see what breaks (usually gems) and then start picking away at things. It's most likely that your code isn't the one that breaks, but gems will. Then it's often just going through each gem that stopped working, looking at their documentation and seeing if you're any major version numbers behind. Follow their upgrade process and one after another, you should get there slowly.

It took me 3 weeks or something (not fulltime) to upgrade our app from Rails 4.1 to 4.2 because of all the gem dependencies we have that needed changing.

On a side note, I think you can just use render text: "asdf" on Rails 4.x and earlier without having to use render plain: "asdf" plus you can pass in an option if you need to change the content type.

Reply

Thanks for the fast reply!

If I'm being honest I thought the OneMonth acquisition was going to end up badly for GoRails etc, but it seems my fears were unfounded. So that's great! I found OneMonth's rails app didn't really help me much in my attempts to learn Rails (which made me sad).

I've just recently felt like I've started to get the concepts/what the code actually is doing which is great because I've spent over a year or two trying to learn Rails. GoRails has been a big help for me and I'd be super interested to see the screencast on the upgrade process. I find it INCREDIBLY hard to find good videos on Rails development that are clear enough to understand and in-depth enough to not bore me.

So thanks for the clear and indepth videos! I'll get plugging away at the update stuff again, it should be mostly simple for my app, I was only using a few Gems (mostly things like bootstrap-sass and font-awesome) and there wasn't much actual code there until this past week... it was mostly just a glorified static website with one or two controllers/models.

Reply

Haha! I don't think we would have done the acquisition if it wasn't to make things better.

Rails is definitely a tough nut to crack. It took me a long time to learn it and I was already familiar with building things in Python.

With some simple gems, you'll probably just need to upgrade the core Rails code and the rest of it should be pretty good to update just buy updating gems.

Reply

Sorry to bump an old post. But I wanted to chime in on my experience with the upgrade process.

I recently upgraded a Rails app from 3.2.21 -> 4.0 The biggest issues I ran into were my models and controllers since the 4.x.x series introduced strong_params. So there was a lot of manual work to get things working properly with Rails conventions and getting away from attr_accessible. Once I got past that mess, like Chris said the gems are a pain in the ass. Especially if you are changing Ruby versions as well as updating Rails. I'm pretty much done with the upgrade but it's taken me over a month to solve all the gem problems that crept up. But really it's just taking one step at a time and getting it nailed down.

Hope your upgrade goes smoothly!

Reply

The migration to strong_params is definitely a big part. It's not complicated but it's quite tedious. A few years ago we wrote and published a gem that should take you 90% of the way there: https://github.com/fastruby/rails_upgrader

In case anyone finds this interesting, here is the process we usually follow at my company: https://www.fastruby.io/blog/rails/upgrades/our-rails-upgrade-process.html

Here is the TL;DR version:

  • Find all deprecation warnings
  • Fix all deprecation warnings
  • Set up dual booting (this can help: https://github.com/fastruby/next_rails)
  • Get bundle install to work
  • Get your test suite to work
  • Get the application to work in production environment
  • Smoke test thoroughly
  • Deploy
  • Monitor exceptions in your favorite error tracker

I know this was asked ages ago, but I figured this might be useful if anybody finds this question in their searches. :)

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.