Created
February 20, 2016 05:59
-
-
Save kirkelifson/d08ccca26d1f234492ad to your computer and use it in GitHub Desktop.
Map relation containing id and model to instances
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
# Example: | |
# approvable_id = 7 | |
# approval_type = "Finding" | |
# Finding.find(7) is yielded | |
Approval.pluck(:approvable_id, :approvable_type).sort.uniq.map { |id, type| Object.const_get(type).find(id) }.count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment