aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-11-09 11:27:46 +0000
committerJon Leighton <j@jonathanleighton.com>2012-11-09 11:43:15 +0000
commitaae4f357b5dae389b91129258f9d6d3043e7631e (patch)
tree653a11901502610f0d6c963e9db8b209b225a244 /guides
parent6710f057f9033aec2ef62b961b9a2000a2d499e5 (diff)
downloadrails-aae4f357b5dae389b91129258f9d6d3043e7631e.tar.gz
rails-aae4f357b5dae389b91129258f9d6d3043e7631e.tar.bz2
rails-aae4f357b5dae389b91129258f9d6d3043e7631e.zip
Nullify the relation at a more general level.
This allows us to avoid hacks like the "return 0 if owner.new_record?" in #count (which this commit removes). Also, the relevant foreign key may actually be present even on a new owner record, in which case we *don't* want a null relation. This logic is encapsulated in the #null_scope? method. We also need to make sure that the CollectionProxy is not 'infected' with the NullRelation module, or else the methods from there will override the definitions in CollectionProxy, leading to incorrect results. Hence the nullify: false option to CollectionAssociation#scope. (This feels a bit nasty but I can't think of a better way.)
Diffstat (limited to 'guides')
0 files changed, 0 insertions, 0 deletions