Skip to content

Commit

Permalink
Merge pull request #12418 from makaroni4/fix/ar_reload_doc_12101
Browse files Browse the repository at this point in the history
Update AR reload doc for the case of manually set primary key attribute [ci skip]
  • Loading branch information
senny committed Oct 2, 2013
2 parents 18ca3cb + 7f1e875 commit 4d38d33
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions activerecord/lib/active_record/persistence.rb
Expand Up @@ -335,8 +335,17 @@ def toggle!(attribute)

# Reloads the record from the database.
#
# This method modifies the receiver in-place. Attributes are updated, and
# caches busted, in particular the associations cache.
# This method finds record by its primary key (which could be assigned manually) and
# modifies the receiver in-place:
#
# account = Account.new
# # => #<Account id: nil, email: nil>
# account.id = 1
# account.reload
# # Account Load (1.2ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT 1 [["id", 1]]
# # => #<Account id: 1, email: 'account@example.com'>
#
# Attributes are updated, and caches busted, in particular the associations cache.
#
# If the record no longer exists in the database <tt>ActiveRecord::RecordNotFound</tt>
# is raised. Otherwise, in addition to the in-place modification the method
Expand Down

0 comments on commit 4d38d33

Please sign in to comment.