Skip to content

Instantly share code, notes, and snippets.

@shuhei
Last active December 20, 2015 01:39
Show Gist options
  • Save shuhei/6050903 to your computer and use it in GitHub Desktop.
Save shuhei/6050903 to your computer and use it in GitHub Desktop.
Inconsistency of ActiveRecord Association. Need to reload before `exists?` but not for `size`.
@foo = @parent.foos.build(name: 'Foo')
@foo.bars.build(greeting: 'hello')
@foo.save
@foo.bars.exists? # -> nil
@foo.bars.size > 0 #-> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment