Exploring the New Features of Rails 8: Solid Cable, Solid Queue, Propshaft, Kamal 2.

Total Blog Views: 96

Blog Status: publish

Created By: swaz_ahmed Created at: 02-12-2025

Tags: ror rails8 kamal solid solid cable solid cache solid queue propshaft kamal2 features

All New Features of Rails 8: What’s Coming to the Table?

Ruby on Rails has always been a beloved framework for building web applications, thanks to its simplicity, flexibility, and developer-friendly features. With Rails 8, the framework has received several exciting new additions that help improve the performance, developer experience, and functionality of applications. Whether you're building a new app or upgrading an existing one, Rails 8 offers powerful tools to make your job easier.

In this blog, we’ll explore the most exciting new features in Rails 8, providing practical examples and insights into how they can improve your development workflow.

 

1. Turbo 8 and Hotwire Integration

Turbo Frames and Streams are part of the Hotwire framework introduced in Rails to reduce reliance on JavaScript for dynamic updates. Turbo 8, in particular, brings several improvements to speed up page interactions without needing full-page reloads.

Example: Turbo Frames for Partial Updates

Here’s how you can use Turbo Frames to update parts of a page without reloading the entire page:

<!-- app/views/posts/index.html.erb --> 
<h1>Posts</h1>

<%= turbo_frame_tag "posts" do %>
 <%= render @posts %> 
<% end %>

<!-- app/views/posts/_post.html.erb --> 
<div id="post_<%= post.id %>"> 
<h2><%= post.title %></h2>
 <%= link_to 'Show', post_path(post), data: { turbo_frame: "post_#{post.id}" } %> </div>

<!-- app/views/posts/show.html.erb --> 
<%= turbo_frame_tag "post_#{@post.id}" do %> 
<h1><%= @post.title %></h1> 
<%= @post.content %> 
<% end %>

 

How it works:

  • When you click on the "Show" link, only the content within the post_<%= post.id %> frame will be replaced. This allows for faster updates and a smoother user experience.

 

2. New Default for ActiveRecord: STRICT Mode

Rails 8 introduces STRICT Mode to ActiveRecord, which ensures that database queries are more reliable and consistent. This new feature can be incredibly helpful in catching database issues early.

Example: STRICT Mode in Active Record

In STRICT Mode, if you attempt to insert a NULL value into a column that should not accept NULL values, Rails will throw an exception.
 

# app/models/user.rb 
class User < ApplicationRecord 
validates :name, presence: true 
validates :email, presence: true 
end 

# This will raise an error because 'name' and 'email' are required 
User.create(name: nil, email: '[email protected]')

 

How it works:

  • By enforcing stricter checks on model attributes, Rails ensures that no invalid data makes it into your database.

 

3. Improved Caching Mechanism

Caching in Rails has always been a powerful tool to enhance performance, and in Rails 8, it’s been made even better. Rails 8 introduces cache versioning, eager cache loading, and more caching layers.

Example: Cache Versioning and Expiration

You can easily version cache keys and manage cache expiration using Rails 8.

 

# app/controllers/posts_controller.rb 
class PostsController < ApplicationController
  def index 
   @posts = Rails.cache.fetch('posts', version: 'v1') do
     Post.all.to_a 
   end 
  end
end

 

How it works:

  • The cache is versioned with the version: 'v1' parameter. This means that when you update your posts (or change any cached data), you can force the cache to expire by changing the version number.

 

4. Async Querying with Active Record

Rails 8 introduces asynchronous queries to Active Record, enabling non-blocking database operations that improve the performance of your application.

 

 # app/controllers/posts_controller.rb
 class PostsController < ApplicationController
  def index 
   # Perform an async database query 
   @posts = Post.where(published: true).async_find_each do |post| 
   # Process each post asynchronously 
   Rails.logger.info("Processing post #{post.id}") 
  end 
 end 
end

 

How it works:

  • async_find_each allows you to process records without blocking the main thread, which is useful when dealing with large datasets or long-running queries.
  • This feature helps avoid delays in response times by running queries in the background.

 

5. Deeper Integration of Webpacker with Rails 8

Rails 8 has deepened the integration of Webpacker, which is used to manage JavaScript, CSS, and other front-end assets. Webpacker now fully supports Webpack 5, allowing you to take advantage of the latest JavaScript tooling.

Example: Using Webpacker to Import JavaScript Modules

 // app/javascript/packs/application.js
 import { helloWorld } from './modules/hello_world'
 helloWorld()

 // app/javascript/modules/hello_world.js
 export function helloWorld() { 
  console.log('Hello from Webpacker and Webpack 5!')
 }

How it works:

  • Webpacker now supports Webpack 5’s optimizations and features, such as tree-shaking, caching, and module federation. This makes it easier to manage modern front-end dependencies within your Rails application.

 

6. Better Developer Experience with New Debugging Tools

Rails 8 introduces better debugging tools, including an integrated performance profiler and improved rails console.

Example: Using the New Performance Profiler

# app/controllers/posts_controller.rb 
class PostsController < ApplicationController 
  def index # Start profiling Rails.performance do
   @posts = Post.all
  end
 end
end

How it works:

  • Rails 8 now includes built-in performance profiling, allowing you to measure the time it takes for specific operations to complete. This is invaluable for diagnosing performance bottlenecks during development.

 

7. Support for Ruby 3.x and Beyond

Rails 8 fully supports Ruby 3.x and introduces features such as keyword arguments, pattern matching, and garbage collection optimizations that Ruby 3 brings.

Example: Using Pattern Matching in Rails 8

# app/models/user.rb
 class User < ApplicationRecord
 def self.find_by_status(status)
   case status
   in :active
      active 
   in :inactive
       inactive 
   else
      none
    end
  end
end

How it works:

  • Ruby 3.x’s pattern matching feature allows you to write cleaner and more expressive code. This is especially helpful for dealing with complex conditions or method arguments.

 

8. New Security Enhancements

Rails 8 brings enhanced security features, including stronger CSRF protections and better password hashing mechanisms.

Example: Improved CSRF Protection

# config/initializers/csrf_protection.rb
 Rails.application.config.action_controller.default_protect_from_forgery = true

 

How it works:

  • CSRF protections in Rails 8 are now stronger by default, ensuring that your forms are secure against malicious attacks.

 

Conclusion

With Rails 8, the framework continues to evolve, making web development faster, more efficient, and more secure. Features like Turbo 8, async querying, and improved caching mechanisms will help developers build even more responsive and optimized applications. With the continued improvements to ActiveRecord, Webpacker, and developer tools, Rails 8 solidifies its place as one of the best frameworks for building modern web applications.

Whether you're a Rails veteran or just getting started, Rails 8 brings new tools and features that will make your development process smoother and your applications more powerful.

Happy coding!


swaz_ahmed

I am swaz_ahmed blogger on shadbox. I am influencer,content writer,author and publisher. Feel free to ask me any question and suggestions.



Comments



Buy traffic for your website

About Shadbox

we have the “Get things executed” lifestyle at our place of work. There are not any excuses, no if’s or however’s in our dictionary. committed to navigating the ship of creativity to create cell answers, we resolve the real-lifestyles troubles of our clients and their clients. Our passion for work has won us many awards, year after 12 months.

Services

Downloads