Your SlideShare is downloading. ×
0
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Active record makeover
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Active record makeover

999

Published on

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

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
999
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Active Record Makeover Marty Haught @mghaught http://martyhaught.com
  • 2. Boulder Ruby Longmont, Colorado
  • 3. ActiveRecord feels like
  • 4. Growing tired of this
  • 5. Wished I was driving...
  • 6. ...but I can’t • Existing system • Project already committed
  • 7. or doesn’t make sense • Not the best fit for project • No significant gain • rdbms solves the problem
  • 8. So where’s the love? • Where’s the new hotness • Envious of the nosql gems • Want a better way to model data
  • 9. Rails 3’s ActiveRecord Unpimp your auto
  • 10. Engine’s been rebuilt • ActiveRelation • arel gem - relational algebra • Consistency under the hood
  • 11. Easier to model with • Simpler api • Fully chainable • Lazy loaded
  • 12. find all Rails 2x Rails 3
  • 13. first, last, count Rails 2x Rails 3
  • 14. Finder methods
  • 15. Chainable Rails 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 create delete create! delete_all find update destroy update_all destroy_all exists?
  • 22. Building with where values
  • 23. Lazy loaded • won’t interact with the db until accessed • such as each, map, etc. • force load - all, first, 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 http://github.com/ernie/meta_where http://github.com/ernie/meta_search
  • 30. Got some hotness • new engine • concise and readable • simpler to model • flexible • extendable
  • 31. Go have fun, get dirty
  • 32. Thank you Marty Haught @mghaught mghaught@gmail.com http://martyhaught.com Image Credits wagon - http://www.flickr.com/photos/halfy/3410561333 vw car - http://www.youtube.com/watch?v=qgEvy60bZYI white race car - http://www.flickr.com/photos/33031095@N03/4538638400/ yellow sports car - http://www.flickr.com/photos/retinafunk/57699167/ red sports car - http://www.flickr.com/photos/freefoto/3844246045/ gray sports car - http://www.flickr.com/photos/doramosnoopy/2479741916/ blue sports car - http://www.flickr.com/photos/chorwedel/4398697300/ racing cars - http://www.flickr.com/photos/oizumi/2582189751/

×