Last active
October 13, 2016 14:50
-
-
Save mrzasa/c9583067d917ea8362655f202193eaf7 to your computer and use it in GitHub Desktop.
ActiveRecord::AssociationRelation vs ActiveRecord::Associations::CollectionProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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