Talking head
Wicked Good Ruby 2013

This presentation, by Neeraj Singh, is licensed under a Creative Commons Attribution ShareAlike 3.0
80x15

ActiveRecord is complex code and because of complexity it has edge cases. In fact lots of edge cases. We will take a look at a number of ActiveRecord features to see how it works and how to deal with some of the edge cases. We will see how default_scope works. And why method "unscoped" removes default_scope from models but not from associations. Do you know the difference between CollectionProxy and Relation ? Do you know why in a has_many through case "@physician.patients.create!" would work but "@physician.patients.where(active: true).create! would silently fail without creating the association record? We will discuss why while patching Active Record you should run your tests against all three databases. Guess which of these two obey :destroy option: @customer.orders.delete(@order) or @customer.orders.destroy(@order). In Rails 3 when where conditions are merged then the last where condition wins. In Rails 4 all the where conditions are 'And'ed. But not defautl_scope. We will see how and why. Will also discuss implementation detail of features like inverse_of, autosave and callbacks.

Rated: Everyone
Viewed 1,530 times
Tags: There are no tags for this video.