Rails upgrade notes
mouse 154 · person cloud · link
Last update
2019-07-19
2019
07-19
«rails notable/interesting changes from v4 to edge»

TODO





New in rails (till 2019-07-06)

ActiveRecord

ActionView

ActiveJob / background jobs

ActionCable / websockets

Frontend

Email

ActiveStorage / upload to cloud -- guide

Security & Paranoia

Core/config changes

Development

  • rails console --sandbox don't write changes to DB -- PR+cfg
  • byebug > 8.2.1 is faster
  • faster dev reload: set in Gemfile group :development{gem 'listen', '~> 3.0.4'}

Tools / External gems

Testing

Info / Minor changes / Good to know


Upgrade experiences -- google search


References


Tools

  • scaling ruby apps
  • 📺 DHH youtube videos on writing sw well
  • MiniMagick
  • ruby's set: a collection of unordered values with no duplicates
  • obj.method(:method_name).source_location => mostra dov'e' definito il metodo
  • <<~TAG ... TAG al poso di <<-TAG...TAG rimuove gli spazi di indentazione!
  • thor -- build powerful command-line interfaces

Benchmark howto

docs, ips extension, article

1
2
3
4
5
6
7
8
9
require 'benchmark'

a = [:a, :b]
b = :b
n = 10000000
Benchmark.bm do |x|
  x.report { n.times do !(Array(a) & Array(b)).empty? end }
  x.report { n.times do Array(a).include?(b) end }
end
1
2
3
4
5
6
7
8
require 'benchmark/ips' # instructions per second
require 'uri'

uri = 'http://example.com/foos_json?foo=heyo'

Benchmark.ips do |x|
  x.report('URI.parse') { URI.parse(uri) }
end

vedi esempi di barnchmark in Hash#deep_merge PR


Books