Guest User

Untitled

a guest
May 20th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. @landlord = Landlord.first
  2.  
  3. # generates a SQL query for the associated properties collection
  4. @landlord.properties.size # => 30, or whatever
  5.  
  6. @landlord.properties.size # => 30; no additional SQL query generated
  7.  
  8. # generates the following SQL in Rails 2.3.5:
  9. # SELECT count(*) AS count_all FROM `properties` WHERE (`properties`.landlord_id = 1)
  10. @landlord.properties.count # => 30
Add Comment
Please, Sign In to add comment