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
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
If you run into any of the following webpacker errors:
Webpacker configuration file not found
Please run rails webpacker:install Error: No such file or directory @ rb_sysopen .../config/webpacker.yml
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!
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.
Running tests in parallel
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:
Active Support, and
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)
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.
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
Yeah, ActionText is just a thing to simplify blog-like sites and CMS like admin panels, nothing more.
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)
Yep, definitely! I'm excited to try out ActionText
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.
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...
I do not have any problem in running my RoR Vue application there.
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:
-----> Detecting rake tasks
! Could not detect rake tasks
! 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.
! 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 envfor more information
! To install the version of bundler this project requires, run
gem install bundler -v '2.0.1'
load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)$ bundle exec rake -P
ensure you can run
against your appbundle update --bundler`......
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
Would love to use new rails and appreciate any buildpack info or tutorials...
I am using this
You do not require to update your bundle to have