instance method
extract_associated
Ruby on Rails 6.1.7.10
Since v6.0.6Signature
extract_associated(association)
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)
Parameters
-
associationreq
Source
# File activerecord/lib/active_record/relation/query_methods.rb, line 199
def extract_associated(association)
preload(association).collect(&association)
end
Defined in activerecord/lib/active_record/relation/query_methods.rb line 199
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::QueryMethods