Active record makeover

download Active record makeover

of 32

  • date post

  • Category


  • view

  • download


Embed Size (px)


15 minute talk given at Red Dirt Ruby Conf in Oklahoma City - May 6th

Transcript of Active record makeover

  • 1.Active Record MakeoverMarty Haught@mghaught

2. Boulder Ruby Longmont, Colorado 3. ActiveRecord feels like 4. Growing tired of this 5. Wished I was driving... 6. ...but I cant Existing system Project already committed 7. or doesnt make sense Not the best t for project No signicant gain rdbms solves the problem 8. So wheres the love? Wheres the new hotness Envious of the nosql gems Want a better way to model data 9. Rails 3s ActiveRecordUnpimp your auto 10. Engines been rebuilt ActiveRelation arel gem - relational algebra Consistency under the hood 11. Easier to model with Simpler api Fully chainable Lazy loaded 12. nd all Rails 2x Rails 3 13. rst, last, count Rails 2x Rails 3 14. Finder methods 15. ChainableRails 2x Rails 3 16. What about scopes? Rails 2x Rails 3 17. Reusing scopes 18. Merging scopes 19. Using scoped 20. Mix and match 21. Behaves like the model new createdelete create! delete_all nd update destroy update_all destroy_all exists? 22. Building with where values 23. Lazy loaded wont interact with the db until accessed such as each, map, etc. force load - all, rst, last 24. Plays nice with caching 25. Modeling with class 26. to_sql 27. where_values 28. Extend the possibilities ActiveRecord::QueryMethods opens a door invokes to_sql on where_values unless a String pass in your own objects that create sql 29. MetaSearch & MetaWhere Ernie Miller 30. Got some hotness new engine concise and readable simpler to model exible extendable 31. Go have fun, get dirty 32. Thank you Marty Haught@mghaught mghaught@gmail.comhttp://martyhaught.comImage Credits wagon - vw car - white race car - yellow sports car - red sports car - gray sports car - blue sports car - racing cars -