Skip to content

Instantly share code, notes, and snippets.

@kirkelifson kirkelifson/meta.rb
Created Feb 20, 2016

Embed
What would you like to do?
Map relation containing id and model to instances
# 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
You can’t perform that action at this time.