Shopify's path to Rails 3

Shopify Engineering
8 min readintermediate
--
View Original

Overview

Shopify successfully upgraded to Rails 3, experiencing minor improvements in response times and benefiting from a cleaner API that facilitates faster feature development. The upgrade process was complex, involving extensive preparation and addressing various challenges unique to their large and established Rails application.

What You'll Learn

1

How to prepare a large Rails application for upgrading to a major version

2

Why using Bundler is essential for managing dependencies in Rails applications

3

When to address XSS vulnerabilities during a Rails upgrade

4

How to effectively manage routes during a Rails upgrade

5

Why thorough testing of external service integrations is crucial during upgrades

Prerequisites & Requirements

  • Understanding of Rails application architecture and upgrade processes
  • Familiarity with Bundler for dependency management(optional)

Key Questions Answered

What challenges did Shopify face during the Rails 3 upgrade?
Shopify encountered several challenges during the Rails 3 upgrade, including managing a large number of routes, updating libraries for compatibility, and addressing XSS vulnerabilities. They also faced issues with helper methods due to changes in Rails 3, which required careful testing and adjustments to their codebase.
How did Shopify prepare for the Rails 3 upgrade?
Shopify focused on preparing their application ahead of the Rails 3 release by using Bundler for dependency management and addressing XSS vulnerabilities well in advance. They also made incremental changes and maintained a separate branch for Rails 3 development to manage the upgrade process effectively.
What improvements did Shopify notice after upgrading to Rails 3?
After upgrading to Rails 3, Shopify observed minor improvements in overall response times and appreciated the new API, which allowed for cleaner code and faster feature development. This transition was seen as beneficial despite the challenges faced during the upgrade process.
What is the significance of using Bundler in Rails applications?
Using Bundler in Rails applications is significant as it helps manage dependencies effectively, ensuring that the application runs smoothly with the required libraries. Shopify found that Bundler improved their deployment process and stability, making it a crucial step before upgrading to Rails 3.

Key Statistics & Figures

Number of active developers on Shopify
11
Shopify started with only 2 active developers and has grown significantly over the years.
Total number of commits to the Shopify codebase
12000
This reflects Shopify's status as one of the oldest and most active Rails projects.
Number of files in app/models directory
327
This indicates the scale of the application and the complexity involved in the upgrade.
Number of routes in the application
846
Managing this large number of routes was a significant challenge during the upgrade process.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Rails
The primary framework used for building the Shopify application.
Tools
Bundler
Used for managing dependencies in the Shopify application.

Key Actionable Insights

1
Prioritize using Bundler for dependency management before upgrading your Rails application.
Bundler significantly simplifies managing dependencies and can prevent issues during major upgrades. By adopting it early, you can streamline your upgrade process and reduce potential obstacles.
2
Conduct thorough testing of all views and helpers to address XSS vulnerabilities before upgrading.
Given the shift to a 'safe by default' XSS behavior in Rails 3, ensuring that your application is secure from the start is critical. This proactive approach can save time and prevent security issues post-upgrade.
3
Keep your routes organized and updated to leverage the new routing API in Rails 3.
The new routing API offers a cleaner and more efficient way to manage routes. By restructuring your routes during the upgrade, you can enhance maintainability and readability in your codebase.

Common Pitfalls

1
Failing to update all helper methods can lead to unexpected behavior after upgrading.
In Rails 3, the behavior of helper methods changed, which can cause conflicts if not properly managed. It's essential to review and update all helpers to ensure compatibility with the new framework.

Related Concepts

Rails Upgrade Processes
Dependency Management With Bundler
Xss Vulnerabilities In Web Applications