ActiveSupport
Upgrading Rails: Everyone can do it and here’s how

Summarized using AI

Upgrading Rails: Everyone can do it and here’s how

Andrea Fomera • May 17, 2022 • Portland, OR

The video titled "Upgrading Rails: Everyone can do it and here’s how" by Andrea Fomera at RailsConf 2022, addresses the common challenges faced when upgrading a Rails application. Andrea emphasizes that upgrading should be treated as a feature rather than a burden.

The key points discussed throughout the talk include:

  • Understanding the Overwhelm: Andrea shares her personal experiences and feelings of dread associated with the release of new Rails versions and the risks of using outdated versions.
  • The Need for Upgrading: Staying up to date is crucial for performance improvements, security updates, and access to recent features, as older versions lack extensive documentation and might not attract developers.
  • Key Considerations for Upgrades:
    • Buy-in from management and team members is essential as management might not see the upgrade as a priority.
    • A robust test suite is vital to minimize risks during the upgrade process.
    • Compatibility of Ruby and dependencies must be assessed; out-of-date gems can halt upgrade progress.
  • Common Approaches to Upgrading:
    • Hiring Outside Help: Companies can pay professionals to perform the upgrade if internal resources are limited.
    • Long-running Branch Strategy: Upgrading in a separate branch can become complicated and lengthy, risking merge conflicts.
    • Dual Booting: This preferred approach allows running two versions of Rails simultaneously, minimizing disruption and risk during the upgrade process. Andrea provides detailed steps for implementing dual booting in applications and shows how to manage different dependencies effectively.
  • Practical Tips and Tools: Suggestions like using tools such as Dependabot and creating roll-out plans for testing upgrades enhance the upgrade experience. Andrea stresses the importance of addressing deprecation messages, updating the Gemfile, and creating a safe rollback strategy.

The talk concludes by encouraging attendees that, while the process is daunting initially, it becomes easier with each subsequent upgrade as developers become more familiar with the necessary steps and techniques.

Upgrading Rails: Everyone can do it and here’s how
Andrea Fomera • May 17, 2022 • Portland, OR

Ever felt overwhelmed when figuring out how to upgrade a Rails app? Unsure where you should begin? We’ll talk about how upgrading should be treated as a feature, and how you can get buy-in from management for upgrading Rails. Have you heard about how GitHub or Shopify uses dual-booting to run two versions of Rails at once and wondered how that works? We’ll talk about three approaches you can use to upgrade your app. You’ll leave this talk with takeaways you can put into practice for your next Rails upgrade.

RailsConf 2022

00:00:00.900 Welcome in. Today, I wanted to talk about upgrading Rails. If you've never done it or considered upgrading a Rails application, it can feel overwhelming to consider the process and figure out all the steps required.
00:00:13.219 So today, we'll give you a short overview of the three most common approaches to upgrading, and then we'll do a deeper dive into dual booting and how every app can take advantage of it. If you've ever felt that sense of dread knowing that a new version of Rails was about to be released, and that your version was quickly headed toward its end of life, meaning it wouldn't receive critical security updates anymore, I understand how you feel.
00:00:45.059 Today, you're going to be able to apply the insights from today's talk to almost any version, though we won't delve into specifics for each version—only the process. I've completed seven Rails upgrades, and this is what I wish I knew when I started. Just a heads up: my slides move quickly, so if you're trying to take notes, don't worry. The slides will be available at the end of the talk.
00:01:21.000 So, who am I? My name is Andrea Fomera, and my pronouns are she/her. I'm a senior product developer at Podia, and I've created a few courses, one of which is building a real-time form with Hotwire. You can access it for free on my website if you're curious. You can find out more about me at afromera.dev. If you're curious to learn about Podia, it's an all-in-one platform for selling courses, webinars, downloads, and community engagement. You can learn more at podia.com, and I want to thank them for making it possible for me to be here today.
00:02:05.399 This is actually my first time in Portland, and I'm super excited. Thank you all for coming to my talk. I'm also incredibly nervous, so bear with me. It’s also my first time attending RailsConf, which is exciting.
00:02:16.200 I want to start off today with a story, but it’s a scary one. This recounts the first time I upgraded Rails professionally. Imagine working on a Rails 4.2 application and being six months into the process of upgrading to Rails 5.0. You finally get all your tests passing!
00:02:27.480 Hooray, right? You've made it to the finish line! But just when you think you're done, someone merges in more code—a new feature that changes 3,000 lines and adds 60 files for a new test. Suddenly, you have to merge in their changes. It was a disappointing moment for me; I cried a little, maybe yelled a bit. I realized that I had to repeat so much of the work I had spent the last six months on.
00:03:04.819 I wondered, was there a better way to do this? I didn’t know of any other way than merging in changes in a branch and trying to get it all passing. There is a better way, and we're going to talk about that today. So when did I actually finish that upgrade? In January 2018. As I was looking through my tweets, I realized how much I wanted to give this conference talk, which is why I'm so thankful to be able to present it today.
00:04:02.400 You might relate to feeling overwhelmed at the thought of an upgrade, but I genuinely believe that everyone can upgrade, even if it may seem like a massive undertaking. However, I won't lie; sometimes it can just be a lot of work. So, take it one step at a time. If you’re using Rails 4.2, don’t just jump straight to Rails 5.2; you must do it step by step.
00:05:01.259 Things did get a bit more efficient once I reached Rails 5.0. We upgraded to 5.1 in April 2018, and then to 5.2 that same May. However, I wouldn’t attempt the Rails 6 upgrade at that job; it felt easier to just leave instead.
00:05:44.420 You might be wondering, why should I upgrade if it's so much work? Staying updated allows you to take advantage of performance improvements, as companies like GitHub and Shopify continually enhance the Rails codebase. Up-to-date software means bug fixes and staying current with the latest technologies, which are more attractive to developers. No one wants to work on a Rails 3 application.
00:06:50.220 The benefits of upgrading include access to security updates and useful features that saturate the framework without increasing overhead, such as Action Cable, Active Storage, Hotwire, and multiple database support, which is subsequently easier to implement.
00:07:20.679 When upgrading, consider whether you have good team buy-in. It's crucial to have support from your team and upper management. If you don't, it can be challenging to gather the necessary time and resources to keep your apps updated. Management may not see upgrading as a feature, which can be difficult to tackle. Using persuasive arguments about the long-term benefits to your business can be effective.
00:08:18.600 Secondly, make sure you have a good test suite. Low or no test coverage increases your upgrade risk and complicates the upgrade process. During upgrades, we want to minimize risk as much as possible. You might have to supplement low test coverage with more tests or manual testing, which adds to the workload.
00:09:19.020 Lastly, you'll need the willpower and persistence to get through unexpected errors. If you were sitting next to me during my upgrades, you'd hear me asking, 'What does it mean in weights? Why did that happen?' It can be frustrating, but it's all part of the process.
00:09:55.740 Additionally, ensure your Ruby version is up to date. Rails 7 requires Ruby 2.7, for example. Here’s a helpful resource showing different Rails versions with their corresponding release dates and compatible Ruby versions. Avoid being on outdated versions, as you should be working your way out of that red zone!
00:10:42.180 Check for out-of-date gems or dependencies you might have. If you’re relying on additional gems for core functionality—like data migration gems or active record extensions—consider if you can streamline those before the upgrade.
00:11:04.500 It's overwhelming to think about these challenges, especially if you're not familiar with your application codebase. It’s incredibly beneficial to get help from a teammate who's more knowledgeable about the app. Outdated gems were a significant hurdle for my first professional upgrade.
00:12:13.020 These outdated dependencies are potential blockers that can prevent your app from bundling and booting correctly with a new Rails version. It can be tricky to decipher errors that occur during the bundling process.
00:12:48.480 Using a dependency management tool can streamline the upgrade process for you. Tools like Dependabot automate PRs based on pending gem updates, allowing you to incrementally upgrade your gems and minimize disruption.
00:13:24.000 Now, let’s discuss the three approaches to upgrade your application. The first approach is outsourcing; it may sound silly, but if your company has the budget and doesn’t want you taking the time for it, they can hire someone else to do it for you. However, ensure you have an adequate test suite. One upgrade service might charge 70-80% of their fee as a client.
00:14:12.120 The second approach is what I call the long-running branch strategy. This involves creating a new branch for your Rails upgrade, making all necessary configurations, and ensuring all tests pass before merging it back. This strategy can become cumbersome as you may keep merging new changes into the main branch.
00:14:40.680 Finally, the third and my preferred approach is dual booting—commonly used by larger companies like GitHub and Shopify. This allows you to run both versions of Rails simultaneously, switching between them. The idea is to implement changes progressively, making it easier to manage and reducing the disruption for other developers.
00:15:37.260 Regardless of the strategy you choose, you'll follow a similar approach. Whether you’re doing the upgrade yourself or outsourcing to another company, an upgrade checklist is crucial. As you upgrade continually, you can build on this checklist and refine the steps each time.
00:16:26.540 You need to start by addressing deprecation messages in your application. Generally, Rails teams try to deprecate features in advance, so if you see warnings in your app, fix them as soon as possible. After that, in the gem file, upgrade Rails to the desired version, while being cautious about dependencies.
00:17:02.220 Make sure to check the Rails upgrade guide for notable changes. Trying to run the new Rails app update command or generating a fresh Rails app to compare with the old configuration can provide great insights into what’s changed. Before the upgrade, always have a rollback plan validated to mitigate any risks that may arise from modifying the session or cookie management, among other critical components.
00:18:01.259 Like earlier discussed, every upgrade carries risks, and it's essential to balance them against potential rewards. If managed correctly, upgrading can yield tangible benefits, but the entire team needs to work together to ensure a smooth transition. Evaluating whether your upgrades go off the rails or succeed will depend significantly on effective communication and strategy execution.
00:18:57.360 To help facilitate better management and dialogue around upgrades, understand the potential pushbacks from stakeholders, especially those fearing risks. Emphasize how the upgrade can be done safely, limit risks, and outline the potential benefits in terms of performance and new features.
00:19:45.540 Take this process slowly—upgrade your gems independently, engage with available resources such as documentation, and practice rollback scenarios. If it's your first time tackling a Rails upgrade, it might feel intimidating, but it will get more manageable with experience. It is absolutely worth the effort.
00:20:31.740 I love to engage with others about upgrading Rails, dependencies, and best practices for development. Thank you all for your attention. If you're looking for the slides, they will be available shortly.
00:21:19.780 You can connect with me through the details provided on the screen. I genuinely appreciate everyone being here today.
00:21:29.059 Thank you, and I hope you enjoy the rest of the conference!
Explore all talks recorded at RailsConf 2022
+68