Rails 8.0 is out

Rails 8.0.0.beta1 brings simplicity with killer features such as a new authentication system and reduced dependency overhead.

Rails 8.0 has arrived, bringing along many exciting new features that aim to simplify and empower the Rails development workflow.

Authentication

"The medicine you don’t wanna take but it’s good for you" – DHH

Rails 8.0 introduces a new authentication approach, designed to provide clarity and guide developers effectively.

"Rails 8 is not going to ship with Devise. It’s not going to ship with a black box security" – DHH

Is this the beginning of the end of separate authentication gems?

The authentication setup is implemented through the generate command. When you execute the command bin/rails generate authentication, it will generate the necessary files to start the basic authentication setup.

Below is the list of files generated by the command:

app/models/current.rb
app/models/user.rb
app/models/session.rb
app/controllers/sessions_controller.rb
app/controllers/passwords_controller.rb
app/mailers/passwords_mailer.rb
app/views/sessions/new.html.erb
app/views/passwords/new.html.erb
app/views/passwords/edit.html.erb
app/views/passwords_mailer/reset.html.erb
app/views/passwords_mailer/reset.text.erb
db/migrate/xxxxxxx_create_users.rb
db/migrate/xxxxxxx_create_sessions.rb
test/mailers/previews/passwords_mailer_preview.rb

As you can see it has the whole structure needed for sessions, password reset, and user management. It solves 90% of the cases, but if you need to customize it, you can do so by changing the generated files.

Solid Trifecta

Modern web applications used to require multiple data storage. One is for websocket updates, another is for cache, and another is for the main data.

We don’t need this anymore. We can collapse all of them into a single storage device. SSD drives are fast enough to make the difference between them and RAM is barely used for most operations.

Solid Trifecta is a set of database-backed adapters that can replace traditional Redis, RabbitMQ, and other storage systems.

Solid Cable for Action Cable

Solid Cable is a database-backed adapter for ActionCable that uses the main database to store the websocket updates.

Solid Cache

Solid Cache is the new and default cache adapter for Active Support.

Solid Queue

Now this is a killer feature: Solid Queue. It reduces the overhead of having a queue system by eliminating the need for multiple gems and complex configurations. It’s easy to set up whether you’re deploying a single server or a dedicated queue server.

Solid Queue also allows for recurring jobs.

The Trifecta is fully featured for the three major database systems: MySQL, PostgreSQL, and SQLite.

Thruster

Thruster is a non-config by default, HTTP/2 proxy for simple production-ready deployments of Rails applications. It runs alongside the Puma webserver to provide a few additional features that help your app run efficiently and safely on the open Internet:

  • HTTP/2 support
  • Automatic TLS certificate management with Let’s Encrypt
  • Basic HTTP caching of public assets
  • X-Sendfile support and compression, to efficiently serve static files

Thruster is installed by default (to skip use --skip-thruster) and will be
used to serve your Rails application in production.

In the Dockerfile generated by rails new you will see the following line:

CMD ["./bin/thrust", "./bin/rails", "server"]

What more?

  • Propshaft is now the default asset pipeline for Rails applications. It’s a modern, fast, and simple asset
    pipeline.
  • Kamal Rails 8.0 will generate a config/deploy.yml for Kamal deployments. This can be skipped with the --skip-kamal option.
  • New internal page for notes: a page at /rails/info/notes, that displays the same information as bin/rails notes.
  • Migrations not-null modifier: During migration generation you can use bang ! to add null: false to the column
    (e.g. bin/rails generate migration CreateUsers email_address:string!:uniq password_digest:string!).
  • Query log tags enabled by default in the development environment: This can be used to trace troublesome SQL statements back to the application code that generated these statements.
  • Deprecate bin/rake stats: Replaced with bin/rails stats.

Conclusion

From development to deployment, Rails 8.0 makes it easier to address common web development challenges. With Solid Trifecta, you can reduce the complexity of your stack and make it easier to maintain and scale your application. With Authentication, you can have a clear path to follow and understand what’s going on in your application which empowers you to make better decisions.

I’m excited to see what the community will build with Rails 8.0.

Happy coding and count on Codeminer42 if you need help migrating or introducing your team to Rails 8!

References

We want to work with you. Check out our "What We Do" section!

Edigleysson Silva

I own a computer

View all posts by Edigleysson Silva →