Ruby on Rails has been the backbone of countless web applications for nearly two decades. With each new version, it keeps getting faster, smarter, and more user-friendly. And now, Rails 8 is here, bringing a fresh wave of powerful features, smarter tools, and exciting updates.
No matter if you're a seasoned Rails developer or just curious about what’s new, this latest release has something to make your work easier, your apps better, and your coding journey more enjoyable.
Let’s get to know Rails 8 and explore how it’s shaping the future of web development.
Ruby on Rails 8 is here, and it’s packed with groundbreaking features designed to make building, deploying, and scaling applications even simpler. From built-in authentication to turbocharged background processing, Rails 8 is a testament to its philosophy as the One Person Framework.
An exciting array of features, bug fixes, and enhancements are being brought about by the latest version of Ruby on Rails. In addition to adding new features and optimization to make Rails development even more efficient and pleasurable, this release expands upon the framework of Rails 7.2.
Important features include the addition of Propshaft as the new default asset pipeline, major ActiveRecord upgrades, and an interface with Kamal 2 for hassle-free deployments. Additionally, Rails 8 offers a number of SQLite integration enhancements that make it a practical choice for production use.
Introduction to Rails 8 Authentication: Rails 8 simplifies user authentication by providing a built-in solution right out of the box. Whether you're building a small app or a large-scale application, Rails 8 makes it seamless to secure user access.
Here are the key features of Ruby on Rails 8:
Multi-Factor Authentication (MFA) add an extra layer of security with native MFA support.
Example implementation:
Rails.application.config.authentication.mfa = true
Ruby on Rails 8 improve password hashing. It utilizes modern hashing algorithms like Argon2 for secure password storage.
Another key feature of Ruby on Rails 8 is encryption enhancements. It provides out-of-the-box encryption for sensitive data using Rails 8's updated cryptographic standards.
Best Practices:
Here are the new features in Ruby on rails 8:
Propshaft replaces Sprockets as the default asset pipeline in Rails 8, offering simplicity, speed, and better integration with modern front-end tooling. Propshaft is build on an era where bundling asset to save on HTTP connections is no longer urgent.
Key Improvements:
How to Transition to Propshaft:
gem 'propshaft', '~> 1.0'
Real-World Example: Propshaft improved asset loading times by 40% in a recent project by streamlining how files were served in production.
Solid Trifacta is a new library that improves type safety in Ruby. It allows developers to declare types explicitly, catching errors earlier in the development cycle. But, why it matters when we already have safety measures in Rails 8. Well, here are the reasons why Solid Trifacta matters:
Integration Guide
To integrate the Solid Trifacta, follow this integration guide:
class User
include Solid::Trifacta
attribute :email, String
end
Pro Tip: Use Solid Trifacta in conjunction with Sorbet or RBS for even greater type safety.
Thruster is the latest addition to Rails 8, designed to handle background jobs more efficiently than ever. It provides a lightweight yet powerful alternative to ActiveJob. With Thruster, there is zero configuration and your web pages run as fast as they can, reducing the time of loading pages.
Here are the key advantages of Thruster:
Sample Implementation:
class
EmailJob
< Thruster::Job
queue_as :emails
def perform(
user_id
)
UserMailer.welcome_email(
user_id
).deliver_now
end
end
Best Practices
To effectively use the Thruster, make sure to follow these practices:
What’s New in Kamal 2? Kamal 2 is the next iteration of Rails’ deployment tool, making zero-downtime deployments and rollbacks simpler and faster. No matter where you’re deploying your application. Kamal takes a fresh Linux box and turns it into an application or necessary server with just a single “Kamal setup” command.
New Features:
Follow this step-by-step guide to deploy Kamal 2 on ruby on rails 8:
To start with, install Kamal 2 in your sysytem.
gem install kamal
After installation, the next step is to configure kamal.yml:
deploy:
app: my_app
servers:
- 192.168.1.1
The last step is to deploy kamal for proper setup.
kamal deploy
Here are the key changes introduced in Ruby on Rails 8:
Rails 8 is a game-changer for developers. From its enhanced authentication capabilities to its modern asset pipeline and deployment tools, it continues to uphold its promise of simplicity and power. Whether you're a solo developer or part of a team, Rails 8 equips you to build scalable and secure applications effortlessly.
Work with future-proof technologies