Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 19, 2019 11:00 am GMT

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 -vruby 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 -vRails 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!


Original Link: https://dev.to/chrisachard/rails-6-released-what-does-that-mean-for-you-3591

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To