DEV Community

Cover image for Rails 6 released - What does that mean for you?
Chris Achard
Chris Achard

Posted on • Originally published at chrisachard.com

Rails 6 released - What does that mean for you?

This was originally posted on: chrisachard.com

Rails 6 was released on August 15, 2019 with a blog post by DHH

So - what's new, and what about old Rails versions?

Rails 4 & 5

Support for Rails 4 is fading fast

The official Rails maintenance policy still lists Rails 4.2.Z as receiving Severe Security Issue patches - but it's already been taking off the regular security issue patch list.

So if you're still on Rails 4 - now is the time to start the upgrading.

Rails 5 is still just fine

Rails 5.0.Z is still on the severe patches list, and Rails 5.2.Z is still receiving regular security updates; so you're still OK on Rails 5 (especially 5.2 or higher)

Stay on top of security issues

If you're concerned about keeping up to date with the latest security issues in Rails, check out the Rails Security Policy or subscribe to the Rails Security Mailing List

How to Get the New Version

Follow these steps to get Rails 6, based on your current status:

Make sure you have Ruby 2.5.0 or higher

Check your ruby version:

$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
# Need to update!

If it's less than 2.5.0, then you have to upgrade first. I reccomend using RVM for that, and you can install RVM and the latest Rails, all with one command:

$ \curl -sSL https://get.rvm.io | bash -s stable --rails

If you already have RVM installed, then you can upgrade to the latest ruby with:

$ rvm install 2.6.3 
$ rvm use 2.6.3 --default 

then update your gem version if needed:

$ gem update --system 
Latest version already installed. Done.

Installing the latest Rails version

With Ruby >= 2.5, you can get the latest Rails:

$ gem install rails -v '6.0.0'
Fetching concurrent-ruby-1.1.5.gem
# ...
Building native extensions. This could take a while...
# ...
40 gems installed

Now, check your rails version!

$ rails -v
Rails 6.0.0

Making a new rails project

With Rails 6 installed, you can make a new project with:

$ rails new MyAwesomeProject
# ...
$ cd MyAwesomeProject
# ...
$ rails start

NOTE

If you run into any of the following webpacker errors:

Webpacker configuration file not found

OR

Please run rails webpacker:install Error: No such file or directory @ rb_sysopen .../config/webpacker.yml

OR

RAILS_ENV=development environment is not defined in config/webpacker.yml, falling back to production environment

Then you probably need to update your yarn version. Use the yarn docs to upgrade, and then run:

$ rails webpacker:install

or delete the project and create a new one with rails new MyAwesomeProject

Once that all works - go to localhost:3000 in a browser, and you're using the new version of Rails!

Running Rails

Upgrading existing projects

If you have a Rails project on 5.2, then you can update with the rails app:update command:

$ rails app:update

or for Rails 4.2 or lower, you can use the rake version of the same task:

$ rake rails:update

For much more technical details about what to expect when upgrading, check out the official Rails upgrade docs.

What's New and Exciting

Ok - you have Rails 6 now... what is new and interesting!?

Webpacker by default

I love mixing React into Rails projects and webpacker is often the best choice for adding npm dependencies into Rails projects.

Now you don't have to worry about the best way to set it all up - because webpacker is built in!

Built in rich text editor

The Trix editor is a rich text editor made by Basecamp. With Rails 6, it's included automatically as Action Text.

To get it working, check out the Action Text Overview, or this video by DHH which walks you through setting it up.

Trix Editor

Running tests in parallel

WooHoo!

If you've worked on any large Rails projects before - then you know how long it can take to run some test suites.

Now - there is finally a built in way to parallelize your tests.

Loads of other little improvements

For a complete list of all the changes, you can view the changelogs of each individual part of Rails:

Action Cable,
Action Mailer,
Action Pack,
Action View,
Active Job,
Active Model,
Active Record,
Active Storage,
Active Support, and
Railties

Should you use Rails 6?

If you are starting a new Rails project today - I would definitely start with Rails 6. It's officially supported now - and if you look at some of the CHANGELOGS above, you'll see that many of the subsystems have been stable for many months.

If you have a project on Rails 5.2 or higher - then you have some time before you have to do anything. If you're not interested in any of the major announced updates then you'll still be getting security updates for awhile.

You could still try running rails app:update though, just to see how much has changed for you particular app - which will give you an idea of how much work it will be when you do decide to upgrade.

If you have a project on Rails 5.0 or lower - then I would definitely consider upgrading sooner rather than later. It will take more work to upgrade these older projects (especially Rails 4 and below) - but security updates are already stopped for Rails < 4.2 - so now (right after a major release) is a good time to update (so that you don't have to do it again for awhile).

So what am I going to try first?

I showed how to make MyAwesomeProject above, so I'm going to take this chance to try out Action Text - the built in rich text editor looks awesome and easy to use.

Once I get that working, I'll post an article about it - so join my newsletter to hear about that in the future!

Top comments (10)

Collapse
 
antonmelnyk profile image
Anton Melnyk • Edited

Thanks for the post! Rails indeed deserves some love besides generis 'Ruby is dead' posts 🥰

I love new 6 version. With ActionText you can basically make your own blog in a few hours from scratch seamlessnessly and Webpacker by default is a great thing for modern web development.

Collapse
 
rutix profile image
Goran

I was happy when I saw ActionText but then got disappointed when I tested it. Missing features like adding attributes on html tags, only h1 headings etc... and they have no intention to add those features

Collapse
 
antonmelnyk profile image
Anton Melnyk

Yeah, ActionText is just a thing to simplify blog-like sites and CMS like admin panels, nothing more.

Collapse
 
chrisachard profile image
Chris Achard

Yes, it is very opinionated. There are a few ways to extend it, but no way to go "full custom" with it (as far as I know)

Collapse
 
chrisachard profile image
Chris Achard

Yep, definitely! I'm excited to try out ActionText

Collapse
 
azeemh profile image
azeemh

Does it work on heroku? Heroku still uses bundler < 2.0 lol i cant even deploy a vue app using webpacker on rails 5.2.3 6 looks awesome but i will hold off on updating to 6 till i can actually use it irl.

Collapse
 
chrisachard profile image
Chris Achard

It should, yep!

Though you may have to do a few configuration things that may be different (like specify a ruby version). Here are some details from heroku: devcenter.heroku.com/articles/gett...

Collapse
 
ruanltbg profile image
Ruan Carlos

I do not have any problem in running my RoR Vue application there.

Collapse
 
azeemh profile image
azeemh • Edited

Werd how did you get it to run? I have problems getting yarn to install... (deploying from github repo)

From build log yesterday that failed:
Installing yarn-v1.16.0
-----> Detecting rake tasks
!
! Could not detect rake tasks
! ensure you can run $ bundle exec rake -P against your app
! and using the production group of your Gemfile.
! Activating bundler (2.0.1) failed:
! Could not find 'bundler' (2.0.1) required by your /tmp/build_7c94768b24d8efa6cb17f46e4e81df42/Gemfile.lock.
! To update to the latest version installed on your system, run bundle update --bundler.
! To install the missing version, run gem install bundler:2.0.1
! Checked in 'GEM_PATH=/tmp/build_7c94768b24d8efa6cb17f46e4e81df42/vendor/bundle/ruby/2.6.0', execute gem env for more information
!

! To install the version of bundler this project requires, run gem install bundler -v '2.0.1'
!
/app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/rake_runner.rb:106:in load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run
$ bundle exec rake -Pagainst your app
and using the production group of your Gemfile.
Activating bundler (2.0.1) failed:
Could not find 'bundler' (2.0.1) required by your /tmp/build_7c94768b24d8efa6cb17f46e4e81df42/Gemfile.lock.
To update to the latest version installed on your system, run
bundle update --bundler`......

Would love to use new rails and appreciate any buildpack info or tutorials...

Thread Thread
 
ruanltbg profile image
Ruan Carlos

I am using this

RUBY VERSION
   ruby 2.6.2p47

BUNDLED WITH
   1.17.2

You do not require to update your bundle to have webpacker (4.0.7) install