Updating My Daily Calendar App: A Journey from Rails 5 to Rails 7 Background

Updating My Daily Calendar App: A Journey from Rails 5 to Rails 7

Published on October 20, 2024

I’ve always enjoyed working on personal projects, and one of my favorites is my daily calendar app. It’s a page-a-day calendar where users can create an account, set up a calendar, and upload 365 or 366 images. The app displays the calendar online and sends an email every day with an image, simulating the experience of a physical page-a-day calendar.

Recently, I decided it was time to give this app some much-needed attention. It hadn’t been updated in years, and I wanted to bring it up to speed with the latest technologies. This meant updating to a stable, recent version of Ruby and Rails, and overhauling almost every gem in the Gemfile.

The Plan: Updating Ruby and Rails

My primary objectives were:

Update Ruby to version 3.2.2

Update Rails to version 7.1.4.1

To tackle this, I leveraged Cursor, a powerful code editor that integrates AI assistance. I extensively interacted with the Claude and ChatGPT models, which provided invaluable guidance throughout the process.

One strategy that proved particularly effective was running rails app:update from the command line. This command walks you through updating each file in your application. By using the command line, diff editor, and AI chat assistance, I gained a much deeper understanding of the necessary changes when moving from Rails 5 to Rails 7.

Updating Gems: A Comprehensive Overhaul

With Ruby and Rails updated, the next step was to update all the gems in the Gemfile. This included:

Bootstrap: Upgraded from Bootstrap 4 to Bootstrap 5.3.

Devise: Updated to the latest version and removed the devise-bootstrap-views gem.

Sidekiq: Moved from Sidekiq 4 to Sidekiq 7.

Redis: Updated to ensure compatibility with Heroku.

Shrine: Upgraded from version 2 to version 3.

Uppy: Updated the JavaScript libraries for the Uppy dashboard.

Saying Goodbye to Old Gems

I also took the opportunity to remove some gems that were no longer necessary:

Uglifier: No longer needed for JavaScript compression.

Devise Bootstrap Views: Removed in favor of custom views compatible with Bootstrap 5.

Bootstrap Upgrade: From 4 to 5.3

One of the most notable updates was moving from Bootstrap 4 to Bootstrap 5.3. I updated the gem and switched to the newer framework. Using Cursor in combination with AI assistance, I updated all of my view code to align with Bootstrap 5’s syntax and classes.

Remarkably, I was able to hand over the entire views directory to the AI model, and it updated all the view files accordingly without missing a beat. The process was smooth, and everything worked as expected.

Revamping Devise and Devise Invitable

Updating Devise involved a few key steps:

Removed devise-bootstrap-views Gem: This gem was no longer compatible, so I opted to create custom views.

Updated Devise Views: With AI assistance, I updated all the Devise views to work seamlessly with Bootstrap 5.

Updated Devise Invitable: Ensured that the devise_invitable gem was updated to its most recent stable version.

Sidekiq, Redis, and Shrine: The Heavy Lifters

Sidekiq and Redis

Updating Sidekiq from version 4 to 7 was straightforward. I encountered minimal issues, and the transition went smoothly. However, I needed to update the Redis gem since my existing setup wasn’t functioning as expected on Heroku.

Shrine: From Version 2 to 3

Upgrading Shrine was a significant undertaking. Moving from version 2 to 3 involves extensive changes across multiple files:

Shrine Initializer: Updated to reflect new plugin configurations and logic.

Image Uploader Class: Modified to align with Shrine 3’s requirements.

Model Adjustments: Ensured the Day model’s image attribute worked with the new version.

Transition from Versions to Derivatives: One of the biggest challenges was updating from the versions plugin to the derivatives plugin. This required careful attention to ensure existing content continued to function correctly.

Updating Uppy and JavaScript

I also updated the Uppy JavaScript libraries, which provide a drag-and-drop interface for file uploads. This required:

Modifying JavaScript Files: Adjusted scripts to work with the new versions of Uppy and Shrine.

Updating Forms: Changed form structures to ensure they interacted correctly with the updated JavaScript and backend logic.

Overcoming Challenges

The most significant challenges included:

Shrine’s Versions to Derivatives: Ensuring a smooth transition while maintaining existing data integrity.

Promote and Delete Jobs: Updated background jobs to create and persist derivatives appropriately.

Synchronizing Configurations: Brought parity between the Shrine initializer and the image uploader class to avoid conflicts.

Final Touches

Before wrapping up, I revisited other aspects of the app:

Rails Admin: Updated to the latest version and reran the generator to refresh configurations.

General Cleanup: Reviewed and updated every gem in the Gemfile, ensuring they were all on their latest stable versions.

Reflections and Looking Ahead

This update was a significant challenge, but it was incredibly rewarding. Not only did I modernize my app, but I also deepened my understanding of the technologies involved. The use of AI assistance through Cursor, Claude, and ChatGPT was instrumental in streamlining the process.

I’m especially impressed with Cursor’s ability to index the entire codebase and provide context-aware assistance. The integration with AI models made updating legacy apps more manageable than ever before.

Below are some screenshots from the updated Daily Calendar app:

Next Steps

Encouraged by this success, I’m planning to tackle another personal project in the coming weekends. The goal is to apply the same approach to update it with the latest versions of Ruby, Rails, and other dependencies.

Stay tuned for more updates on my journey through code, AI assistance, and continuous learning!

Happy coding!