Upgrading to Rails 6.0

As with all upgrades, remember to pay attention to your deprecation warnings in Rails 5.2 before attempting to switch your Gemfile. Rails 6.0 is a someone esoteric upgrade in which a few features get added but they are mostly optional and it it does not fundamentally make over your Rails app.

Credentials

Ok, for many versions of rails I’ve been squaking about the credentials system doesn’t support different environments— that is, development, staging, production.

Here, finally with Rails 6 we get support multi environment credentials. Rejoice!

That means you can have encrypted credentials for all of your environments. Your key is are now in config/credentials/production.key (don’t commit this file to your version control) and your secrets are encrypted in config/credentials/production.yml.enc

They are available to you automaticlly.

You’ll want this same setup for yoru development and staging (so config/credentials/staging.key and config/credentials/development.key). Again, these keys are not commited to version control. You do commit the coorsponding .yml.enc files. Becuase those are encrypted you know they can only be accessed with the key files.

ActionMailbox

Is for incoming mails into your application. You can route incoming mail to

ActionText

Like Medium or WordPress? Well now Rails can do inline editing, making your selection bold, italics, etc. It even can have media mixed into txt.

Install with rails action_text:install

Both trix and @rails/actiontext should be required in your JavaScript pack

require("trix")
require("@rails/actiontext")

The trix stylesheet should be imported into actiontext.scss

@import "trix/dist/trix";

Then, on your message, you’re going to add

class Message < ApplicationRecord
  has_rich_text :content
end

And finally, in yoru form, you’ll put

<%= form_with model: message do |form| %>
  <div class="field">
    <%= form.label :content %>
    <%= form.rich_text_area :content %>
  </div>
<% end %>

Parallel Testing

Is an automatic, built-in way for you to parallelize your test suite. That means if you have multiple processesors on your computer (you probably do), you can run you run your tests in parallel, or at the same time. For larger app this is excellent because it speeds up your development time.

Action Cable

Important syntax change in your Javascript: App.cable becomes ActionCable

Before

App.cable..createConsumer

After

ActionCable.createConsumer

REMOVALS

• You can no longer use environment with the rails command. Use RAILS_ENV instead.

• Remove deprecated capify! method in generators and templates

• Remove deprecated config.secret_token

I hope you’ve enjoyed this quick overview of Rails 6. Please be sure to Like and Follow on the platform of your choice (below). Wish you the best rest of your day and from the Rails Coach— see you tomorrow for a sneak peak at Rails 6.1

0 Replies to “Upgrading to Rails 6.0”

LOG IN WITH