What Is New in Ruby on Rails 6.0
| Category | Highlights |
|---|---|
| New Features | Action Mailbox, Action Text, Parallel Testing, Action Cable testing tools |
| Improvements | Multiple-database support, bulk-insert APIs (insert_all, upsert_all), Active Storage variant enhancements (BMP, TIFF, progressive JPEG), Webpacker as default JS compiler, null_store as default test cache, expanded rails routes output |
| Deprecations | Deprecated after_bundle helper, config.secret_token, config.environment argument, rack server name argument, HOST env for server IP, config_for non-symbol hash keys, several Action Pack and Action View helpers |
| Removals | Removed after_bundle, config.secret_token, fragment_cache_key helper, image_alt helper, old ActionCable debugging methods, deprecated ActionDispatch::TestResponse methods, and other legacy APIs |
| Breaking Changes | NullStore is now the default cache store in test, config.secret_token removal requires explicit secret_key_base, config_for now returns symbol-keyed hashes, and several helper signatures have changed |
How does Rails 6.0 simplify handling incoming email?
Rails 6.0 introduces Action Mailbox, a framework for routing inbound email to mailbox classes.
Action Mailbox parses incoming messages and dispatches them to controller-like mailboxes, letting you keep email handling logic alongside your regular Rails code.
- Create a mailbox with
rails generate mailbox Support. - Configure inbound routes in
config/routes.rbusingmailbox :support. - Leverage Active Storage to attach files automatically.
# app/mailboxes/support_mailbox.rb
class SupportMailbox < ApplicationMailbox
def process
# business logic here
end
end
This matters if you need to process support tickets, newsletters, or any automated email workflow without pulling a separate mail server library.
What rich-text editing capabilities are built into Rails 6.0?
Rails 6.0 adds Action Text, which integrates the Trix editor and stores content in a dedicated RichText model.
Action Text lets you embed images, galleries, and formatted text directly in your models while handling uploads via Active Storage.
- Generate the RichText model with
rails action_text:install. - Use
has_rich_text :contentin any Active Record model. - In views, render with
form.rich_text_area :content.
# app/models/article.rb
class Article < ApplicationRecord
has_rich_text :body
end
This is useful for blogs, CMS platforms, or any feature that requires user-generated rich content.
How can I speed up my test suite with Rails 6.0?
Rails 6.0 ships with Parallel Testing, allowing tests to run across multiple processes or threads.
By default Rails forks a number of worker processes equal to the CPU core count, dramatically reducing total test time.
- Run
rails test:parallelto execute all tests in parallel. - Use
parallelize(workers: :number_of_processors)insidetest_helper.rbfor custom worker counts. - Threaded mode is available via
--threadsflag.
# test/test_helper.rb
class ActiveSupport::TestCase
parallelize(workers: 4)
end
Watch out for tests that rely on shared state; they may need to be made thread-safe.
What multiple-database features does Rails 6.0 provide?
Rails 6.0 adds first-class multiple database support, including migrations, schema cache, and connection-switching APIs.
This enables you to shard data, separate read-only replicas, or use different databases for legacy tables without leaving the Rails ecosystem.
- Define databases in
config/database.ymlwithprimaryandreplicasections. - Run migrations on a specific database via
rails db:migrate:primaryorrails db:migrate:replica. - Switch connections in code with
ActiveRecord::Base.connected_to(database: :replica) do ... end.
# Example of read-only replica usage
ActiveRecord::Base.connected_to(role: :reading) do
User.find_each { |u| puts u.email }
end
This matters for scaling applications that need to offload reporting queries or comply with data-segregation policies.
Frequently Asked Questions
What command runs only Action Cable channel tests in Rails 6?
rails test:channels
How do I generate a RichText model for Action Text?
rails action_text:install creates the necessary tables and model
Which cache store is used by default in the test environment?
NullStore is the default cache store in test
How can I change the database of an existing Rails 6 app?
rails db:system:change lets you switch the adapter and reconfigure the database
What is the new way to specify the server for rails server?
Use rails server --using puma or the short form -u puma
How do I perform bulk inserts in Rails 6?
Model.insert_all([{name: 'Alice'}, {name: 'Bob'}]) inserts multiple records in a single query