diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-10-01 23:38:14 -0700 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-10-01 23:38:14 -0700 |
commit | 4d38d33de1f3fb029eb4756dcfc08450df8a7337 (patch) | |
tree | 3baac50e82bbf67e02417d81605ce5fd659653fa /activerecord | |
parent | 18ca3cbe12af1464f2991ced0e891ec372c8a449 (diff) | |
parent | 7f1e8759c301101f79327a7473fce4e66c4a2ecb (diff) | |
download | rails-4d38d33de1f3fb029eb4756dcfc08450df8a7337.tar.gz rails-4d38d33de1f3fb029eb4756dcfc08450df8a7337.tar.bz2 rails-4d38d33de1f3fb029eb4756dcfc08450df8a7337.zip |
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]
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index bdd00ee259..21eabd69f2 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -335,8 +335,17 @@ module ActiveRecord # 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 |