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

Blow up when things are wrong

Blow up when things are wrong

When something unexpected happens, you should know about it immediately to make debugging and fixing the problem easier. Discusses ActiveRecord persistence APIs.

Vesa Vänskä

May 13, 2013

More Decks by Vesa Vänskä

Other Decks in Programming


  1. Blow up when things are wrong ActiveRecord edition Vesa Vänskä,

    Kisko Labs Helsinki Ruby Brigade, Rails Girls
  2. 14.6.2012 – #update_attribute is deprecated in 3.2 branch 14.6.2012 –

    #update_attribute was removed from 4.0 branch 24.7.2012 – #update_column was deprecated in 4.0 branch 26.7.2012 – Rails 3.2.7 release 30.7.2012 – #update_column is undeprecated in 4.0 branch 1.8.2012 – #update_attribute is undeprecated in 3.2 branch 25.8.2012 – #update_attribute is put back in 4.0 branch 9.8.2012 – Rails 3.2.8 release
  3. • https://github.com/rails/rails/commit/ b081f6b59fb3f15d12043072ad9b331ffd2bc56e • https://github.com/rails/rails/pull/6738 • https://github.com/rails/rails/pull/1190 • https://github.com/rails/rails/commit/ 4ac81de52fbcdabc68f6d1fa8a5ee9ff7fff7df1

    • https://github.com/rails/rails/commit/ 50bdb924ba26999a468ec4844917cefec39ba08c • https://github.com/rails/rails/commit/ 81542f95d25825a7d3eff87d6f706661bf553b18 Links
  4. I

  5. After all this •In Rails 4 the recommended way is

    to use #update with a hash •#update_attributes is aliased to #update •#update_attribute is still skipping validations
  6. Vesa's laws of updating attributes 1. Use #update_attributes or use

    setters and #save/#save! 2. All other methods of updating attributes need an accompanying comment that explains why you didn't follow the first rule.