The first Rails 8 beta has officially been released, bringing an exciting set of features, bug fixes, and improvements. This version builds on the foundation of Rails 7.2, while introducing new features and optimizations to make Rails development even more productive and enjoyable.
Key highlights include an integration with Kamal 2 for hassle-free deployments, the introduction of Propshaft as the new default asset pipeline, and extensive ActiveRecord enhancements. Rails 8 also brings several SQLite integration upgrades that make it a viable option for production use.
Let's dive in and explore everything that Rails 8 has to offer!
Effortless Deployments with Kamal 2 and Thruster
Rails 8 makes deploying your applications simple with Kamal 2 and Thruster.
Kamal 2 reduces the need for reliance on managed cloud services and Platform as a Service (PaaS) platforms by enabling quick and easy deployment to cloud VMs, bare metal servers, or VPS environments in just minutes.
With a single command (kamal setup
), you can set up a production-ready Rails
environment on a standard Linux box, making deployment both easy and
cost-effective.
Kamal 2 also integrates with Thruster, a custom proxy built specifically for Rails that enables zero-downtime deployments, HTTP/2 support, automated SSL with Let's Encrypt, Gzip compression, and easy hosting of multiple apps on a single server — all without complex setup.
With Kamal 2 and Thruster, Rails 8 makes deploying apps easier than ever. And if
you prefer a different deployment setup, you can opt out using the
--skip-kamal
flag to maintain your existing workflows.
Leaner Rails Deployments with Solid Adapters
One of the big improvements in Rails 8 is simpler deployments by reducing the number of additional services needed to implement common web application requirements.
Traditionally, if you required features like job queues, caching, and pub/sub messaging, you'd use a combination of a database like PostgreSQL with Redis for auxiliary functions.
With Rails 8, you can handle all these with just SQLite, thanks to three new database-backed adapters: Solid Cable, Solid Cache, and Solid Queue.
-
Solid Cable is Rails' new default Action Cable adapter in production and means you can drop the common dependency on Redis. It acts as the pub/sub server, relaying messages between the app and connected clients using fast polling through SQLite. Despite polling, Solid Cable's performance is comparable to Redis in most situations.
-
Solid Cache replaces the need for Redis by using disk storage instead of RAM for caching. This approach allows for much larger, more cost-effective caches that persist longer and handle more requests without sacrificing performance. It also supports encrypted storage and retention policies to meet privacy requirements.
-
Solid Queue replaces Redis for Active Job background processing, using the
FOR UPDATE SKIP LOCKED
mechanism for efficient job handling (compatible with PostgreSQL, MySQL, or SQLite). It includes essential features like concurrency control, retries, and recurring jobs, and has proven itself at HEY, where it now manages 20 million jobs per day.
These three adapters are designed around a simple idea: modern SSDs and NVMe drives are fast enough to handle many tasks that previously required in-memory solutions. By tapping into these speedy drives, Rails cuts out the need for separate RAM-based tools like Redis.
SQLite is Ready for Production
Rails 8 takes SQLite from a lightweight development tool to a reliable choice for production use, thanks to extensive work on the SQLite adapter and Ruby driver.
With the introduction of the solid adapters discussed above, SQLite now has the capability to power Action Cable, Rails.cache, and Active Job effectively, expanding its role beyond just prototyping or testing environments.
Here are some key improvements to the SQLite integration in Rails 8:
- Full-text search and virtual tables are now supported using
create_virtual_table
. - The adapter now allows bulk insert fixtures for enhanced data seeding performance.
- Transactions default to
IMMEDIATE
mode to improve concurrency. - Enhanced error handling by translating
SQLite3::BusyException
intoActiveRecord::StatementTimeout
.
A New Era for the Asset Pipeline with Propshaft
Rails 8 also introduces Propshaft as the new asset pipeline default, replacing the long-standing Sprockets system. Sprockets served Rails developers well for over a decade, but it was designed in a different era — before the explosion of JavaScript build tools and modern browser improvements.
Propshaft reflects a simpler, modern approach to managing assets, built around the core needs of today's developers. Its purpose is straightforward: to provide a clear path for assets and apply digest stamps for caching.
Unlike Sprockets, which took on numerous additional tasks, Propshaft focuses only on what's essential, fitting naturally with the new Rails philosophy of keeping asset pipelines lean (while complex JavaScript handling is left to specialized tools like Esbuild or Vite).
Built-In Authentication Made Simple
Rails has been building the key components of authentication over the years,
from has_secure_password
in Rails 5 to normalizes
, generates_token_for
and
authenticate_by
in
Rails 7.1.
With Rails 8, all these components come together to give you a straightforward starting point for building a secure, session-based authentication system.
By running a single command, you can set up all the essentials for an authentication system with database-backed sessions and password reset functionality:
This command generates key files, including models, controllers, mailers, and views:
This effectively puts you on the fast track to secure, production-ready authentication. All that's left is to integrate a user sign-up flow customized to your application's needs.
New Script Folder and Generator
Rails 8 introduces a new script
folder dedicated to holding one-off or
general-purpose scripts, such as data migrations, cleanup tasks, or other
utility operations. This addition helps organize these scripts neatly, keeping
them separate from your main application logic.
To make script creation easier, a new script generator is available. You can generate scripts with a simple command:
These commands create the corresponding script files, which you can then execute with:
This streamlined approach keeps your application organized and makes handling custom scripts more convenient and maintainable.
A Slew of Active Record Improvements
Active Record has also seen major enhancements in Rails 8 to improve performance, simplify migrations, improve troubleshooting, and provide better support for complex database use cases.
Below are some of the key changes introduced in this latest version:
- Rails 8 now distinguishes between
float4
andfloat8
in PostgreSQL. drop_table
now supports dropping multiple tables at once.- Support for PostgreSQL table inheritance and native partitioning has been added.
- Bulk inserts of fixtures are now supported to improve data seeding performance.
- Migrating a fresh database now starts by loading the database schema before running the migrations.
create_schema
anddrop_schema
operations are now reversible.- Rails 8 now requires MySQL 5.6.4 or later due to advancements like datetime with precision.
- Query log tags are enabled by default in development environments to trace SQL statements back to the application code and identify which database is in use.
Wrapping Up
Rails 8 introduces a range of impactful updates, from easier deployments with Kamal and a modern asset pipeline to significant ActiveRecord enhancements and improved production capabilities for SQLite.
These advancements not only boost developer productivity but also align with modern best practices, allowing you to focus on building your application instead of dealing with infrastructure complexities.
For a detailed list of all the new features, optimizations, and changes, check out the official Rails 8 release notes.
If you want to get involved with contributing to Rails, visit the Rails GitHub repository to explore open issues and review the contribution guidelines.
Thanks for reading!
P.S. If you'd like to read Ruby Magic posts as soon as they get off the press, subscribe to our Ruby Magic newsletter and never miss a single post!