Reputation: 19737
I'm building an Active Record query over a few lines:
query = ForumThread.joins(:posts)
query = query.where(:posts => {:some_integer => 123})
No query is executed for results = query
. However results = query.all
works. What does call .all on the ActiveRecord::Relation do?
Upvotes: 1
Views: 2218
Reputation: 2059
When you say
results = query
all you are doing is making results equal to the query object.
When you call
results = query.all
You are sending the all method to query (which says get all of the records that match the query) and assigning the result to results.
Upvotes: 3