Together, we explore experimenting in production with Ruby on Rails. We learn about various techniques and how the `scientist` and `lab_tech` Ruby gems can help us achieve safe and scientifically-driven experimentation.
0 do |balance, transaction| balance + transaction.amount end end end class BankAccount < ApplicationRecord has_many :transactions def balance transactions.sum(:amount) end end @garyhtou
might give inaccurate results 💸 new_balance # calculation using `sum` end end class BankAccount < ApplicationRecord has_many :transactions def balance old_balance # calculation using `reduce` end end @garyhtou
< 0.5 old_balance else new_balance end end end class BankAccount < ApplicationRecord has_many :transactions def balance old_balance # calculation using `reduce` end end A/B Testing @garyhtou
def balance old_result = old_balance # calculation using `reduce` new_result = new_balance # calculation using `sum` if new_result != old_result puts "oh no! new method is wrong! 😰" end old_result end end @garyhtou