Upgraded our Open Source Job Board App (DollarJobs) from Rails version 6.1 to 7.0.0 and then to 8.0.0

Chetan MittalChetan Mittal
5 min read

Keeping your Ruby on Rails application up-to-date is essential for maintaining security, optimizing performance, and leveraging the latest features.

This post outlines our experience upgrading our open source job board application (DollarJobs) from Rails 6.1 to Rails 7.0.0 and then to Rails version 8.0.0.1.

We’ll share our methodology, challenges, best practices, and how this upgrade has positioned us for future growth.


Preparation and Planning

Upgrading a Rails application is not merely about bumping a version number. It involves meticulous preparation to identify potential risks and ensure a smooth transition.

Before starting, we:

  1. Reviewed the Rails Upgrade Guide: The official guide provided clarity on changes between versions and areas requiring attention.

  2. Assessed Ruby Version Compatibility: Rails 7.0 necessitated upgrading to Ruby 3.x, so we evaluated the impact of this move.

  3. Audited Dependencies: We identified outdated gems and those incompatible with Rails 7.

  4. Analyzed Framework and Breaking Changes: Rails 7 introduced major changes, particularly in Active Record, the asset pipeline, and default configurations.

See the Upgrade Git Diff.

These steps laid a strong foundation for the upgrade.


Key Upgrade Steps

1. Ruby Version Update

Rails 7.0 requires Ruby 2.7.2 or later, but we opted for Ruby 3.1.0 to maximize future compatibility and leverage performance enhancements.

Upgrading the Ruby version necessitated careful checks for:

  • Syntax Changes: Adapting code to align with Ruby 3.x syntax.

  • Gem Compatibility: Ensuring gems supported the new Ruby version.

Changes:

# Before
ruby '2.7.0'

# After
# ruby '3.1.0'
ruby '3.3.6'

2. Rails Version Bump

Updating the Rails version was the centerpiece of this upgrade.

We incremented the version in our Gemfile and ran bundle update rails to fetch the latest dependencies.

Changes:

# Before
gem 'rails', '~> 6.1.0'

# After
# gem 'rails', '~> 7.0.0'
gem 'rails', '~> 8.0'

3. Dependency Updates

Several core dependencies were updated to ensure compatibility with Rails 7. Highlights include:

  • ActiveAdmin: Upgraded from 2.9.0 to 3.2.5 for compatibility and new features.

  • Annotate: Updated to 3.2.0 for maintaining schema documentation.

  • Devise: Bumped to 4.8.1 to maintain user authentication support.

  • Spring: Upgraded to 4.1 to leverage improved preloading in Rails 7.

These updates required extensive testing to identify deprecated methods and breaking changes.


4. Supporting Gems

Rails 7 introduced breaking changes that required us to add or adjust supporting gems, including:

  • Webrick: Added for local development compatibility.

  • Brakeman: Upgraded to 5.4 for security scanning.

  • Colorize, REXML, Psych: Addressed compatibility with Ruby 3.x.

  • Kramdown Parser GFM: Ensured Markdown rendering for blog integration.


5. Sprockets and Asset Handling

Rails 7 shifts towards an updated asset pipeline. We upgraded Sprockets to version 4.2, which improved asset compilation and caching.


6. Jekyll and Blog Integration

To maintain the blog section of DollarJobs, we updated Jekyll and related gems:

  • Jekyll: Upgraded to 3.10 for modern Ruby compatibility.

  • Jekyll Feed & SEO Tag: Updated to their latest stable versions.


Screencast

Challenges and Considerations

1. Dependency Compatibility

Ensuring all gems worked seamlessly involved:

  • Resolving Conflicts: Manually updating or replacing incompatible gems.

  • Deprecation Warnings: Addressing methods flagged for removal in Rails 7.

2. Breaking Changes

Rails 7 introduced significant updates, including:

  • Active Record Changes: Updated default associations and query behavior.

  • Asset Pipeline Overhaul: Adjusted configuration for JavaScript and CSS assets.

3. Code Refactoring

Adapting to new Rails configurations required careful code refactoring, especially in areas tied to Active Record and asset handling.


Performance and Security Benefits

The upgrade delivered tangible benefits, such as:

  • Enhanced Security: Patched vulnerabilities in Rails 6.1.

  • Optimized Performance: Improved database query handling and caching.

  • Modern Features: Leveraged Ruby 3.x and Rails 7 improvements for faster development.


Testing and Validation

Post-upgrade testing was critical. We:

  1. Ran Automated Test Suites: Ensured functionality across models, controllers, and views.

  2. Performed Manual Testing: Validated edge cases and integration points.

  3. Monitored Logs: Checked for deprecation warnings and runtime errors.


Lessons Learned

  1. Stay Proactive: Regularly update dependencies to avoid technical debt.

  2. Leverage Documentation: Use official guides and community forums for clarity.

  3. Test Thoroughly: Incremental testing prevents regression issues.

  4. Invest in Test Coverage: High test coverage mitigates risks during upgrades.


Conclusion

Upgrading from Rails 6.1 to Rails 7.0.0 was a substantial effort but yielded significant rewards in performance, security, and maintainability.

By methodically addressing dependencies, testing thoroughly, and embracing Rails 7’s new features, the DollarJobs application is now positioned for long-term success.


Next Steps

  1. Monitor Compatibility Issues: Continue tracking dependencies for updates.

  2. Plan for Rails 8: Evaluate the cost-benefit of a Rails 8 upgrade. UPGRADED TO Rails 8. See the Git Diff - https://github.com/bestwebventures0/dollarjobs/compare/upgrade_to_rails_700...upgrade_to_rails_8

  3. See the “Upgraded to Rails 8 screenshot” as below.

  4. Optimize Current Setup: Focus on stabilizing the Rails 7 Rails 8 implementation.

Screenshot - Upgraded to Rails 8 successfully

Rails 8 Upgrade Considerations

While Rails 8 is available, its adoption requires:

  • Substantial Refactoring: Adaptation to breaking changes.

  • Significant Testing Efforts: Ensuring stability post-upgrade.

  • Strategic Planning: Aligning the upgrade with business goals.

  • Moving away from JQuery to Stimulus/Hotwire. Better to keep Vanilla JS or JQuery for petty JS tasks.

For now, our focus remains on reaping the benefits of Rails 7 Rails 8 while strategically planning for future updates.

0
Subscribe to my newsletter

Read articles from Chetan Mittal directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Chetan Mittal
Chetan Mittal

I stumbled upon Ruby on Rails beta version in 2005 and has been using it since then. I have also trained multiple Rails developers all over the globe. Currently, providing consulting and advising companies on how to upgrade, secure, optimize, monitor, modernize, and scale their Rails apps.