DEV Community

Prakash Sanyasi
Prakash Sanyasi

Posted on

Rails 8: New Features and Enhancements for Modern Web Development

Ruby on Rails 8 has arrived, bringing exciting new features, performance improvements, and developer-friendly enhancements. Whether you're upgrading from Rails 7 or starting a new project, Rails 8 continues to streamline web development with its convention-over-configuration philosophy while embracing modern best practices.

In this blog post, we'll explore the key features of Rails 8 with practical examples to help you get the most out of this release.

1. Turbo as the Default Frontend Solution

Rails 8 fully embraces Hotwire (Turbo + Stimulus) as the default frontend approach, reducing JavaScript complexity while maintaining dynamic interactivity.

Example: Real-Time Updates with Turbo Streams

<!-- app/views/posts/index.html.erb --> <%= turbo_stream_from "posts" %> <div id="posts"> <%= render @posts %> </div> <!-- app/views/posts/_post.html.erb --> <%= turbo_frame_tag dom_id(post) do %> <h2><%= post.title %></h2> <p><%= post.body %></p> <% end %> 
Enter fullscreen mode Exit fullscreen mode

Now, any changes to posts (via CRUD operations) automatically update the DOM without full-page reloads.

2. Improved ActiveRecord Async Queries

Rails 8 enhances asynchronous query handling, making it easier to optimize database performance.

Example: Automatic Async Loading

# Rails 7 (explicit async)  posts = Post.where(published: true).load_async # Rails 8 (implicit async when possible)  posts = Post.where(published: true) # Automatically async under the hood  
Enter fullscreen mode Exit fullscreen mode

This reduces boilerplate and improves scalability for I/O-bound applications.

3. Better Multi-Database Support

Rails 8 refines multi-database configurations, making it easier to scale reads and writes across different databases.

Example: Automatic Read Replicas

# config/database.yml  production: primary: database: app_prod replica: database: app_prod_replica replica: true # Models automatically use replicas for reads  User.all # Uses replica if available  User.create!(name: "Alice") # Uses primary DB  
Enter fullscreen mode Exit fullscreen mode

4. Enhanced Security with ActiveRecord Encryption

Rails 8 expands on deterministic and non-deterministic encryption for better security while maintaining queryability.

Example: Encrypted Attributes

class User < ApplicationRecord encrypts :email, deterministic: true # Allows searching  encrypts :ssn, deterministic: false # Fully randomized  end # Querying still works for deterministic fields  user = User.find_by(email: "user@example.com") 
Enter fullscreen mode Exit fullscreen mode

5. Simpler Background Jobs with Solid Queue

Rails 8 introduces Solid Queue, a new built-in database-backed job queue, as an alternative to Active Job adapters like Sidekiq.

Example: Enqueuing Jobs

# config/application.rb  config.active_job.queue_adapter = :solid_queue # Enqueue a job  UserReportJob.perform_later(user_id: 1) 
Enter fullscreen mode Exit fullscreen mode

No need for Redis—just PostgreSQL or MySQL!

6. Improved Error Pages & Debugging

Rails 8 introduces better error pages with:

  • Enhanced stack traces
  • Code suggestions
  • Integrated documentation links

No more guessing—just faster debugging!

7. Built-In Health Checks

Rails 8 adds standardized health check endpoints for monitoring and Kubernetes readiness.

Example: Adding a Health Route

# config/routes.rb  Rails.application.routes.draw do get "/up", to: ->(env) { [200, {}, ["OK"]] } end 
Enter fullscreen mode Exit fullscreen mode

8. Modern Asset Management with Import Maps by Default

Rails 8 continues promoting import maps for JavaScript dependency management without bundlers.

Example: Adding a JS Library

# config/importmap.rb  pin "lodash", to: "https://ga.jspm.io/npm:lodash@4.17.21/lodash.js" 
Enter fullscreen mode Exit fullscreen mode

No Webpack or Node.js required!

9. Improved Mailer Previews & Testing

Mailer previews now support better organization and dynamic data.

Example: Dynamic Mailer Previews

# test/mailers/previews/user_mailer_preview.rb  class UserMailerPreview < ActionMailer::Preview def welcome_email UserMailer.with(user: User.first || User.new(name: "Test")).welcome_email end end 
Enter fullscreen mode Exit fullscreen mode

10. Faster Development with Zeitwerk Autoloader Optimizations
Rails 8 further optimizes Zeitwerk, reducing reload times in development.

Upgrading to Rails 8
To upgrade:

  • Update your Gemfile:
gem "rails", "~> 8.0.0" 
Enter fullscreen mode Exit fullscreen mode
  • Run:
bundle update rails rails app:update 
Enter fullscreen mode Exit fullscreen mode

Final Thoughts

Rails 8 continues to refine the developer experience with:
✅ Turbo-first frontends (less JavaScript)
✅ Better async & database scaling
✅ Stronger security & encryption
✅ Simpler background jobs (Solid Queue)
✅ Improved debugging & monitoring

Whether building a new app or upgrading, Rails 8 keeps Ruby on Rails fast, secure, and productive.

What’s your favorite Rails 8 feature? Let me know in the comments! 🚀

Top comments (0)