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

Abuse the abusable ActiveRecord ...NOT!

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Abuse the abusable ActiveRecord ...NOT!

We all know that Rails's ActiveRecord is so powerful. By DHH's definition, it's God-like, in this talk I am going to show how to abuse it to solve a simplified usecase of claim lodging. And then show you how to get it right without ActiveRecord!

Avatar for Trung Lê

Trung Lê

March 12, 2014

More Decks by Trung Lê

Other Decks in Technology

Transcript

  1. ClaimA #valid? ClaimB #valid? ClaimC #valid? #save! true false false

    false #errors.add #errors.add #errors.add Claim STI Validation #set_amount true true #set_amount #set_amount Callbacks
  2. • So many responsibilitties • Prone to regressions • Persistence

    Locked • Hard to write test • SLOWWW test • STI?! Gosh NO! • Domain logic mixed
  3. The Lean Way • NO DHH! - Think before you

    listen to him • Only data persistence & validation & assoc. in AR • Split to services • Simplicity over Convention and Convenience