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?
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.
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)
Follow these steps to get Rails 6, based on your current status:
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.
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
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!
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.
Ok - you have Rails 6 now... what is new and interesting!?
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!
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.
For a complete list of all the changes, you can view the changelogs of each individual part of Rails:
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).
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!