Method: ActiveRecord::QueryMethods#extract_associated
- Defined in:
- lib/active_record/relation/query_methods.rb
#extract_associated(association) ⇒ Object
Extracts a named association from the relation. The named association is first preloaded, then the individual association records are collected from the relation. Like so:
account.memberships.extract_associated(:user)
# => Returns collection of User records
This is short-hand for:
account.memberships.preload(:user).collect(&:user)
341 342 343 |
# File 'lib/active_record/relation/query_methods.rb', line 341 def extract_associated(association) preload(association).collect(&association) end |