Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's coming in Rails 5.2, and sneak peek into...

What's coming in Rails 5.2, and sneak peek into Rails 6

The next minor version of Ruby on Rails is right around the corner! Let's look at those new features that are coming in the next few weeks to Rails 5.2, and sneak peek into those new features that will come in Rails 6.0, the next major release of Rails.

Presented at Great Western Rails #3 in Bristol, UK on March 21, 2018 and Tokyo Rubyist Meetup on Apr 4, 2018.

Prem Sichanugrist

March 20, 2018
Tweet

More Decks by Prem Sichanugrist

Other Decks in Programming

Transcript

  1. New Features Custom Mailer Delivery Job H2 Early Hints Headless

    Chrome and Headless Firefox Support DSL for Configuring CSP Header Verbose Query Log One-Way Migration in change block Active Storage Built-in Redis Cache Store ActiveSupport::CurrentAttributes #rails52
  2. Improvements Recycle Cache Keys AEAD Encrypted Cookies Support pg 1.0

    Safer Raw SQL handling New Threshold for Cache Compression freeze_time Bootsnap in Default Gemfile #rails52
  3. NEW Active Storage #rails52 class User < ApplicationRecord # Associates

    an attachment and a blob. When the user # is destroyed they are purged by default (models # destroyed, and resource files deleted). has_one_attached :avatar end class AvatarsController < ApplicationController def update # params[:avatar] contains a # ActionDispatch::Http::UploadedFile object Current.user.avatar.attach(params.require(:avatar)) redirect_to Current.user end end
  4. NEW Active Storage #rails52 # Sprockets (Asset Pipeline) //= require

    activestorage # Yarn/Webpacker import * as ActiveStorage from "activestorage" ActiveStorage.start() # View file <%= form.file_field :attachments, multiple: true, direct_upload: true %>
  5. NEW Active Storage Q: Should I switch to Active Storage

    from [___________]? A: Sure!* #rails52
  6. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1-20180320190000" post.update!({ ...

    }) post.cache_key #=> "post/1-20180320190013" post.update!({ ... }) post.cache_key #=> "post/1-20180320190025"
  7. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1-20180320190000" post.update!({ ...

    }) post.cache_key #=> "post/1-20180320190013" post.update!({ ... }) post.cache_key #=> "post/1-20180320190025" post.update!({ ... }) post.cache_key #=> "post/1-20180320190102"
  8. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1-20180320190000" post.update!({ ...

    }) post.cache_key #=> "post/1-20180320190013" post.update!({ ... }) post.cache_key #=> "post/1-20180320190025" post.update!({ ... }) post.cache_key #=> "post/1-20180320190102" post.update!({ ... }) post.cache_key #=> "post/1-20180320190130"
  9. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1-20180320190000" post.update!({ ...

    }) post.cache_key #=> "post/1-20180320190013" post.update!({ ... }) post.cache_key #=> "post/1-20180320190025" post.update!({ ... }) post.cache_key #=> "post/1-20180320190102" post.update!({ ... }) post.cache_key #=> "post/1-20180320190130"
  10. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1" post.cache_version #=>

    "20180320190000" post.update!({ ... }) post.cache_key #=> "post/1" post.cache_version #=> "20180320190013"
  11. #rails52 https://github.com/rails/rails/pull/29092 Recycle Cache Keys post.cache_key #=> "post/1" post.cache_version #=>

    "20180320190000" post.update!({ ... }) post.cache_key #=> "post/1" post.cache_version #=> "20180320190013" post.update!({ ... }) post.cache_key #=> "post/1" post.cache_version #=> "20180320190025"
  12. Rails 4 AES in CBC mode with HMAC using SHA1

    #rails52 https://github.com/rails/rails/pull/28132 AEAD Encrypted Cookies
  13. Rails 4 AES in CBC mode with HMAC using SHA1

    Rails 5.2 AES-GCM #rails52 https://github.com/rails/rails/pull/28132 AEAD Encrypted Cookies
  14. #rails52 https://github.com/rails/rails/pull/30744 H2 Early Hints Support HTTP/1.1 103 Early Hints

    Link: </application.css>; rel=preload; as=style Link: </application.js>; rel=preload; as=script HTTP/1.1 200 OK Date: Tue, 20 Mar 2018 15:12:00 GMT Content-Length: 4200 Content-Type: text/html; charset=utf-8 Link: </application.css>; rel=preload; as=style Link: </application.js>; rel=preload; as=script
  15. #rails52 https://github.com/rails/rails/pull/30744 H2 Early Hints Support <%= preload_link_tag "application.css" %>

    <link rel="preload" href="/assets/application.css" as="style" type="text/css" />
  16. #rails52 https://github.com/rails/rails/pull/31162 DSL for Configuring CSP Header #config/initializers/content_security_policy.rb Rails.application.config.content_security_policy do

    |p| p.default_src :self, :https p.font_src :self, :https, :data p.img_src :self, :https, :data p.object_src :none p.script_src :self, :https p.style_src :self, :https, :unsafe_inline # Specify URI for violation reports # p.report_uri "/csp-violation-report-endpoint" end
  17. #rails52 https://github.com/rails/rails/pull/31162 DSL for Configuring CSP Header # Override policy

    inline class PostsController < ApplicationController content_security_policy do |p| p.upgrade_insecure_requests true end end
  18. #rails52 https://github.com/rails/rails/pull/26815 Started GET "/news/popular" for ::1 at 2016-10-19 00:5

    Processing by NewsController#popular as HTML Version Load (57.3ms) SELECT "versions".* FROM "ve Verbose Query Log
  19. #rails52 https://github.com/rails/rails/pull/26815 Started GET "/news/popular" for ::1 at 2016-10-19 00:5

    Processing by NewsController#popular as HTML Version Load (57.3ms) SELECT "versions".* FROM "ve ↳ app/views/news/show.html.erb:9:in `_app_views_news Verbose Query Log
  20. #rails52 https://github.com/rails/rails/pull/26815 Started GET "/news/popular" for ::1 at 2016-10-19 00:5

    Processing by NewsController#popular as HTML Version Load (57.3ms) SELECT "versions".* FROM "ve ↳ app/views/news/show.html.erb:9:in `_app_views_news Verbose Query Log
  21. New Threshold for Cache Compression Automatically compress value > 1kB

    #rails52 https://github.com/rails/rails/pull/31147
  22. Bootsnap in Default Gemfile Add gem "bootsnap" for current projects

    #rails52 https://github.com/rails/rails/pull/29313
  23. .create_or_find_by Use Unique index to mitigate possible
 race condition in

    find_or_create_by https://github.com/rails/rails/pull/31989 #rails6
  24. Goodbye ‚ utf8 attribute no longer generated in form_tag by

    default https://github.com/rails/rails/pull/32125 #rails6
  25. Goodbye–✓ utf8 attribute no longer generated in form_tag by default

    https://github.com/rails/rails/pull/32125 #rails6
  26. https://github.com/rails/rails/pull/32130 #rails6 Expanded rails routes $ rails routes --expanded --[

    Route 1 ]------------------------------------------------------------ Prefix | high_scores Verb | GET URI | /high_scores(.:format) Controller#Action | high_scores#index --[ Route 2 ]------------------------------------------------------------ Prefix | new_high_score Verb | GET URI | /high_scores/new(.:format) Controller#Action | high_scores#new --[ Route 3 ]------------------------------------------------------------ Prefix | blog Verb | URI | /blog Controller#Action | Blog::Engine [ Routes for Blog::Engine ] --[ Route 1 ]------------------------------------------------------------ Prefix | cart Verb | GET URI | /cart(.:format) Controller#Action | cart#show