Rails 6 features: An Illustrated Version [INFOGRAPHIC]
Tags: rails, ruby, news
Published: 2019-09-27 10:51:38

Ruby on Rails, the goto framework for startups, launched its much-awaited 6.0 version on August 15, 2019. While the release notes are available [here](https://edgeguides.rubyonrails.org/6_0_release_notes.html), we're presenting an illustrated version of the same.

![Alt ](https://cdn-images-1.medium.com/max/1200/1*4OoePTqsH_mJQuat74Hm6A.png)

Ruby on Rails has evolved over the years and has attracted its fair share of [love and hate](https://blog.solutelabs.com/ruby-on-rails-in-2019-c11956d8cc6f) - but one thing is for sure, with the kind of attention it's garnering and the number of people contributing to it - it's here to stay!

A huge number of expectations were riding on this Ruby on Rails 6 release and the following are the main highlights of the same!

* **Action Mailbox:** Working with incoming email
* **Action Text:** A modern WYSIWYG editor
* Support [Multiple Databases](https://guides.rubyonrails.org/active_record_multiple_databases.html) with Active Record
* Run Test Cases in Parallel, taking advantage of multiple cores
* More ❤ for Javascript
* **Zeitwerk:** a new code loader for Ruby

While the above is a list of major upgrades, there were a lot of minor improvements by a lot of people which shows how active the community around Rails is! Let's dig deeper into each of the updates.

####Action Mailbox
![Alt qandm](https://cdn-images-1.medium.com/max/800/0*LfYbF_NkkVzLWy7f.gif)<figcaption>credits: qandm</figcaption>

Email is a powerful tool to communicate. Almost everyone needs to send emails - but increasingly many are also wanting to add a human touch with their users. In the world of bots, instead of ***do-not-reply*** emails, people are sending emails which can be replied to from real people.

Rails 6.0 now ships with [inbuilt support](https://edgeguides.rubyonrails.org/action_mailbox_basics.html) for Mailgun, Mandrill, Postmark, and SendGrid. The emails are processed via Active Record and stored on the cloud through Active Storage and can be sent to one more multiple mailboxes.

> What it means is that you can build your own mini Zendesk or Intercom with Rails with Action Mailbox and Action Cable

####Action Text
I've seen a lot of WYSIWYG (What You See Is What You Get) editors and have found some issues with almost every one of them, none are perfect and while are minimalistic but lacking features, others are just plain bad.

Most WYSIWYG editors are wrappers around HTML's `contenteditable` and `execCommand` APIs and reverse engineer from there. DHH created this introductory video to explain Trix and it's inclusion in Rails 6 sometime a year ago:

{% youtube HJZ9TnKrt7Q %}

The Action Text includes Active Storage-backed file and image processing, and a text-processing flow that ties it all together. This is especially useful if you're not using any UI framework like [React with Rails](https://blog.solutelabs.com/value-of-using-react-with-ruby-on-rails-df10eaf0f03e).

####Support for Multiple Databases
Today's applications are growing and supporting an enormous amount of users. An application hits limitations by scaling vertically (i.e. adding more RAM and Cores to an existing machine) and it's pragmatic to then scale horizontally (i.e. add more nodes aka machines) to support the growing userbase and this applies to not just app servers but also to Database Servers.

![Alt Server Connected to Multiple Databases](https://cdn-images-1.medium.com/max/600/1*57IXNsvkDBI0iYceLSdI8g.png)

Separating Databases and hence the content also adds security - so, in the worst-case scenario, one database being hacked won't lead to a total compromise of data.

This would also help if we want to keep some type of data in a NoSQL Database (such as location tracking data for trucks) and other data in an RDBMS format.

The support is nascent so while you can:

* Have multiple primary databases with a replica for each (and automatically swap between them)

* Automatically switch between databases depending upon the model on which you're working, and

* The supporting rails tasks to handle multiple databases (create, drop, migrate DBs)

Stuff like the below is in the works:

* Sharding
* Joining across clusters
* Load balancing replicas
* Dumping schema caches for multiple databases

####Run Test Cases in Parallel
Assuming that you're following TDD and BDD model for development (writing test cases before writing the logic), you would have noticed your test suites taking more and more time to run as the application grows.

Some of the apps that we have made took up to 30 minutes to run over a CI server. With multiple cores on your laptop and (hopefully) your CI - with the new [commit](https://github.com/rails/rails/pull/31900), you should be able to run your test cases more efficiently. While forking processes is the default method, threading is supported as well.

To enable parallelization to your test suites, just add the following to your `test_helper.rb` and voila!

```sh
class ActiveSupport::TestCase
 parallelize(workers: 2)
end
```
There are options to set a different count for your CI server, you can dig into more details [here](https://edgeguides.rubyonrails.org/testing.html#parallel-testing).

####More Love for Javascript
One thing is certain, Javascript is here to stay. Over the past few years, instead of fighting Javascript, the Rails community has embraced it with adding support for Vue, React and Angular in Rails 5.1.

Webpacker is now the default JavaScript bundler for Rails through the new app/javascript directory - although CSS and static assets will continue to work through the asset pipeline.

####Zeitwerk
The new default code loader for Rails is here - Zeitwerk. It overcomes much of the limitations of the traditional loader, Zeitwerk can:

* Autoload Code
* Eager Load Code
* Reload Code
* Works with both: Gems and Apps

Listen to a nice talk by Xavier Noria for a deeper dive here:

{% youtube f_IY4iunM8U %}

----
![Rails 6 new features](https://thepracticaldev.s3.amazonaws.com/i/p8gt5l9ouebukbe80i8b.png)


At SoluteLabs, we specialize in creating mobile and web apps for startups and we generally depend on [Ruby on Rails](https://www.solutelabs.com/ruby-on-rails-development-services) to build scalable, secure and fast-to-build backend for our apps.