Skip to content
This repository
Browse code

Merge pull request #12418 from makaroni4/fix/ar_reload_doc_12101

Update AR reload doc for the case of manually set primary key attribute [ci skip]
  • Loading branch information...
commit 4d38d33de1f3fb029eb4756dcfc08450df8a7337 2 parents 18ca3cb + 7f1e875
Yves Senn authored October 01, 2013
13  activerecord/lib/active_record/persistence.rb
@@ -335,8 +335,17 @@ def toggle!(attribute)
335 335
 
336 336
     # Reloads the record from the database.
337 337
     #
338  
-    # This method modifies the receiver in-place. Attributes are updated, and
339  
-    # caches busted, in particular the associations cache.
  338
+    # This method finds record by its primary key (which could be assigned manually) and
  339
+    # modifies the receiver in-place:
  340
+    #
  341
+    #   account = Account.new
  342
+    #   # => #<Account id: nil, email: nil>
  343
+    #   account.id = 1
  344
+    #   account.reload
  345
+    #   # Account Load (1.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT 1  [["id", 1]]
  346
+    #   # => #<Account id: 1, email: 'account@example.com'>
  347
+    #
  348
+    # Attributes are updated, and caches busted, in particular the associations cache.
340 349
     #
341 350
     # If the record no longer exists in the database <tt>ActiveRecord::RecordNotFound</tt>
342 351
     # is raised. Otherwise, in addition to the in-place modification the method

0 notes on commit 4d38d33

Please sign in to comment.
Something went wrong with that request. Please try again.