Rails 8 Update: What’s Changed and How It Improves Development

Rails 8 is here, and it's packed with tools and improvements designed to make development faster, simpler, and more powerful. Let’s dive into the technical details of some standout features in Rails 8, exploring how you can start using them in your projects!

Key Technical Highlights in Rails 8  

1. Kamal/Thruster Deployment Tool

What’s New: Kamal/Thruster introduces a streamlined deployment solution built specifically for Rails applications, aiming to reduce the complexities of cloud deployments.

Technical Tips:

  • Configuration: Kamal requires minimal configuration. You can initialize it with kamal init, which will generate a default config file suited to your environment.
  • Cloud Provider Support: Kamal integrates easily with cloud providers like AWS, GCP, and DigitalOcean. Just specify your provider in the config file, add credentials, and you’re good to go.
  • Rollback Feature: Kamal includes a rollback mechanism, allowing you to revert to a previous version in case of deployment issues, a valuable feature for continuous deployment setups.

Getting Started:

kamal init   # Initialize Kamal in your Rails app
kamal deploy # Deploy your app

2. Enhanced Support for Progressive Web Apps (PWA)  

What’s New: Rails 8 offers extended support for PWAs, making it simpler to add offline functionality and push notifications for a more app-like experience.

Technical Tips:

  • Manifest and Service Workers: Use the built-in Rails helpers to set up a manifest and a service worker, enabling offline capabilities and add-to-home-screen functionality.
  • Asset Caching: Propshaft now integrates seamlessly with service workers to cache assets locally, enhancing offline usability.

3. Solid Adapters for Enhanced Compatibility  

What’s New: Solid Adapters in Rails 8 reduce dependencies by eliminating the need for external services like Redis or Memcached, making deployment easier and more cost-effective. Rails 8 introduces Solid Cable, Solid Cache, and Solid Queue to handle pubsub, caching, and background job processing directly within SQLite, which takes advantage of modern disk speeds and reduces memory reliance.

A Solid Reduction of Dependencies  

Traditionally, Rails relied on external services like Redis (for jobs, caching, and WebSockets) and PostgreSQL/MySQL for full feature access. Now, the new Solid Adapters offer SQLite-based alternatives that tap into the high-speed benefits of SSDs and NVMe drives. This approach eliminates several dependency requirements and simplifies infrastructure.

Solid Cable  

Purpose: Replaces Redis for WebSocket pubsub, allowing SQLite to manage WebSocket message relaying.

Technical Tips:

  • Disk-Based Pubsub: Solid Cable uses fast polling and stores messages in the SQLite database, providing adequate performance for most use cases. Messages remain in the database for a day by default, making it easier to troubleshoot live updates.
  • Installation: Integrate Solid Cable by adding it to your WebSocket configuration and avoiding Redis setup.

Solid Cache  

Purpose: Replaces Redis or Memcached for HTML fragment caching, storing cached data on disk instead of RAM.

Technical Tips:

  • Scalability: Solid Cache allows a much larger and cost-effective cache by leveraging disk storage, ideal for longer cache retention (up to 60 days).
  • Encryption and Retention Policies: Solid Cache allows you to define cache retention limits and encrypt data to meet privacy requirements, providing a more secure solution for storing sensitive content.

Production Insight: Basecamp has successfully run Solid Cache in production for over a year, caching 10 TB of data with 60-day retention, significantly improving response times.

Solid Queue  

Purpose: Eliminates the need for Redis and job-processing frameworks like Sidekiq by enabling SQLite-based background job processing.

Technical Tips:

  • Concurrent Job Processing: Solid Queue includes advanced concurrency management, retries, scheduling, and alerting, making it a feature-rich solution for background processing.
  • Flexibility: Solid Queue works as a Puma plugin for single-server setups or via bin/jobs for running dedicated dispatchers, offering configuration for scaling and performance tuning.
  • High-Performance Setup: For installations requiring high concurrency, Solid Queue utilizes PostgreSQL or MySQL with FOR UPDATE SKIP LOCKED for efficient job handling.

Production Insight: HEY has adopted Solid Queue, running over 20 million jobs daily while replacing six different Resque gems with this unified solution.

4. Propshaft: A New Asset Pipeline

What’s New: Propshaft replaces Sprockets as Rails’ default asset pipeline, offering a simpler and more efficient way to manage assets.

Technical Tips:

  • Migrating from Sprockets: Propshaft is easier to configure and faster in production environments. If you’re upgrading from Sprockets, move your assets into the new app/assets structure used by Propshaft.
  • Asset Compilation: Unlike Sprockets, Propshaft uses fingerprinted URLs out of the box, simplifying asset caching.

5. Built-in Authentication   

What’s New: Rails 8 now includes built-in authentication tools, removing the need for third-party gems like Devise for basic authentication needs.

Technical Tips:

  • Configuration: Use Rails’ built-in authentication generator to scaffold user accounts, sessions, and permissions.
  • Customizable: While the built-in tools provide default functionality, you can extend them by adding custom controllers or modifying existing views to suit specific application requirements.

Getting Started:

rails generate authentication User   # Generates authentication for a User model

6. New Script Folder and Generator   

What’s New: The new scripts folder in Rails 8 organizes your custom scripts and introduces a script generator, simplifying the management of utility scripts.

Technical Tips:

  • Script Organization: Place maintenance scripts, startup scripts, and other custom scripts within scripts, giving them better visibility and structure.
  • Generating Scripts: Use the new Rails script generator to create templates for custom scripts, providing consistency and avoiding boilerplate.

Getting Started:

rails generate script sample_script  # Generates a new script template

7. Active Record Improvements for Precision Data Types  

What’s New: Rails 8’s Active Record now supports float4 and float8 data types, improving precision for numeric data.

Technical Tips:

  • Database Compatibility: Ensure your database supports the new precision data types (e.g., PostgreSQL). This feature is especially valuable in applications that require highly accurate financial or scientific data.
  • Migration Example: To leverage float4 and float8, create migrations that explicitly set these data types.

Getting Started:

Migration to use float4 or float8 in PostgreSQL
def change
  add_column :products, :price, :float, precision: 8  # Precision here is illustrative
end

Each of these new features in Rails 8 offers valuable technical enhancements, simplifying development and providing out-of-the-box solutions for common application needs. Whether you’re handling deployments, improving application speed, or strengthening authentication, Rails 8’s tools are ready to support your project’s growth.

Take advantage of these new tools to streamline your workflow and make your Rails applications more powerful than ever. Ready to get started with Rails 8? Dive in, experiment with these features, and let’s take web development to the next level!

 Conclusion

Rails 8.0 equips developers with an efficient, secure, and scalable framework. Whether you’re aiming for zero-downtime deployments, simplified caching, or seamless authentication, Rails 8.0 empowers you to create high-performing applications with minimal dependency.