instance method
load
Ruby on Rails 8.1.2
Since v4.0.13Signature
load(&block)
Causes the records to be loaded from the database if they have not been loaded already. You can use this if for some reason you need to explicitly load some records before actually using them. The return value is the relation itself, not the records.
Post.where(published: true).load # => #<ActiveRecord::Relation>
Parameters
-
blockblock
Source
# File activerecord/lib/active_record/relation.rb, line 1199
def load(&block)
if !loaded? || scheduled?
@records = exec_queries(&block)
@loaded = true
end
self
end
Defined in activerecord/lib/active_record/relation.rb line 1199
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Relation