What’s new in Rails 6?

What’s new in Rails 6?

What’s new in Rails 6? - This article will introduce you to new Rails 6 features, explain how they should be used, and discuss what they can do to improve your workflow and ...

Rails 6 release date and features

Rails 6 latest version rc2 has now released on July 22, 2019. This may be the best-exercised RC (release candidate) in Rails history. Because Rails has been released with three beta versions so far. Companies like Basecamp, Shopify and Github already using rc1 in the production. If you want to start a new rails app today then definitely you can use 6.0.0.rc1 or 6.0.0.rc2 gem version.

Let’s see what are the Rails 6 new features added in the final release of 6.0.0.rc1

  • Action Mailbox
  • Action Text
  • Parallel Testing
  • Action Cable Testing
  • Webpack

1) Action Mailbox

In Rails 5, we were using ActionMailer to manage mails in the application.

Action Mailbox is extracted from Basecamp, which gives you the way for incoming emails to the mailboxes as a controller for processing in the rails application. Also, it has access to integrate Mailgun, Postmark and SendGrid. Along with that, you can implement and work on handling inbound mails directly via the built-in access to Exim, Postfix and Qmail.

The inbound emails are considered as ‘InBoundEmail’ records using Active Record and tracking of its lifecycle, store original email on cloud storage via Active Storage. Also, it is responsible for data handling with on-by-default destruction process. By default, an ‘InBoundEmail’ that has been successfully processed will be destroyed after 30 days. For more help click here.

NOTE.: Action Mailbox requires Active Job and Active Storage.

2) Action Text

This is another extraction from Basecamp. According to Trix, this is a rich text content and editor for everyday writing that added to Rails 6.

This editor handles everything from formatting, quotes, lists and embedded images and galleries. Any embedded images or attachments are automatically stored using

Active Storage and associated with the RichText model. For more help click here.

Action Text already included in Rails 5.2, so many developers might have used it and also aware of the challenges if they have faced. This will give you opportunities to edit and bring rich text content.

Why was Trix editor added to Rails 6?

Most WYSIWYG editors use HTML’s contenteditable and execCommand that are designed by Microsoft support team for Internet Explorer 5.5. And based on reverse-engineering, those things copied from other browsers, so during implementation, each browser has its own issues and that leads to inconsistency.

But, Trix uses HTML’s contenteditable as an I/O device and overcome this inconsistency.

NOTE.: Action Text requires Active Storage.

3) Parallel Testing

Rails 6 added parallel testing by default. This feature is built by Github. Parallel testing allows you to run each test parallelly. It reduces the time to execute the test suite.

The machine has multiple cores and can create workers too. Using Rails 6, we create workers and based on each worker, Rails create a test-database. So, the test will have these number of database to run the test suite. We can create workers in two ways:

  • By adding parallelize(workers: 2) to your test_helper.rb
  • By adding PARALLEL_WORKERS=2 rails test
  • Example: If you have created 2 workers then the test will create test-database-0 and test-database-1.

If you love to run the test using threads and JRuby, then it has additional property as thread. To add this, you need to add parallelize *(workers: :number_of_processors, with: :threads)* to your test_helper.rb. This threading parallelization is supported by Minitest’s Parallel:: Executor. For more help click here.

4) Action Cable Testing

This is a small feature added in Rails 6. In this, Rails allows testing your action cable functionality at any level. The levels are:

  • Connections
  • Channels
  • Broadcasts

We do a connection test to check the connection’s identifiers are assigned properly or are there any improper connection. Channel tests only assert the channel subscribes to the particular stream or not. The broadcast test is to check whether the message has been broadcasted inside other components. For more help click here.

5) Webpack

Webpack bundler has been added as default in Rails 6. Previously Rails uses Assets Pipeline to built JS and CSS. But now, using webpacker gem, all StyleSheets, images and JS libraries wrap into a single bundle with a single access point.

Some people already using webpack bundling with rails 5.1+ version. But, in that version, we need to configure it using the command ‘rails new app --webpack’. Now, it is by default into the rails app.

Webpack is a static module bundler for modern js applications. Webpack helps during connecting Rails app with UI frameworks like ReactJs, AngularJs, VueJs, etc. Also, using this we can easily build hot reloading into Rails 6 application.

The webpacker gem provides integration with webpack and npm/yarn. Npm and yarn both famous for fast, reliable, and secure dependency management.

Rails 6 upgradation from Rails 5

  • Considerations
  • First, you need to consider your application rails version is 5.2 and you need to upgrade to rails version 6. And your current app rails version has latest patch version before moving to the next major/minor version.
  • Ruby Version
  • Rails 6 require Ruby version 2.5 or greater.
  • Gems
  • You need to check all your gems from Gemfile are compatible with Rails 6 gem. You can check this by visiting the respective gem’s GitHub page.
  • Config files
  • There is a task rails app:update. It will update the app to the latest version. During app updates, it will give you conflict over current files. You need to fix those files carefully.
  • Removals
  • There are many removals in Rails 6. You need to take care of that during upgradation.
  • Webpacker
  • Now, webpacker is by default added in Rails 6. It is a modern javascript compiler. You can manage your asset pipeline using webpacker.
  • Credentials
  • Rails 6 given support for all environment credentials. Means, now you can create separate credentials to each environment e.g. dev, staging and production.

    Why use Ruby on Rails?

  • Ruby is a much-matured language now. Years back, Ruby was slow and Rails was a bit slower but it is history now. Rails 6 will boom popularity worldwide again.
  • As per Stackoverflow survey 2019, Ruby is the sixth most highly paid language worldwide.
  • It has many helpful tools and gems. Using these gems and tools, you can build a web application in a faster way. Many startup’s using RoR for web applications.
  • RoR has a big community to give solution to the developer’s problem. You get solutions online easily for every small and complex issue.
  • Web application performance time you can reduce using background processing, using CDN and indexing your database.
  • Ruby on Rails updates continuously with good features.

    Summary

We hope that this blog will be helpful to learn new features added in Rails 6 as well as the upgradation process. Ruby on Rails playing a very important role in Web Application Development and Web API Development. It will help you to build web applications within less time and cost compared to other technology.

ruby-on-rails web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Ruby on Rails Developer | Hire RoR Developer

#1 Ruby on Rails development company. Hire Ruby on rails developer or a team to build secure, scalable and complex web solutions with a quick turnaround time.

Hire Web Developer

Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...

How to Deploy a Ruby on Rails App on Heroku

The most satisfying thing beyond building something is to make it available to the world. Heroku is great for beginners because it’s a free and “simple” push-to-deploy system.

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

"Rewrite your Software," says Creator of Ruby on Rails

David Heinemeier Hansson is the creator of Ruby on Rails, co-founder & CTO of Basecamp, best-selling author, Le Mans class-winning race car driver, family man, frequent podcast guest, and inspirational conference speaker.