Skip to content

Instantly share code, notes, and snippets.

@mrzasa
Last active October 13, 2016 14:50
Embed
What would you like to do?
ActiveRecord::AssociationRelation vs ActiveRecord::Associations::CollectionProxy
> user.devices.all.uniq.class
=> Device::ActiveRecord_AssociationRelation
# so that we can chain more AR methods
> user.devices.all.uniq.limit(1)
=> [Device]
> u.devices.uniq.class
=> Array
# so we can only work on array:
> user.devices.uniq.limit(1)
NoMethodError: undefined method `limit' for []:Array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment