HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/ruby-2.6.8/doc/activerecord-6.1.4.1/ri/ActiveRecord/Persistence/reload-i.ri
U:RDoc::AnyMethod[iI"reload:ETI"%ActiveRecord::Persistence#reload;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"*Reloads the record from the database.;To:RDoc::Markup::BlankLineo;
;	[I"NThis method finds the record by its primary key (which could be assigned ;TI"2manually) and modifies the receiver in-place:;T@o:RDoc::Markup::Verbatim;	[I"account = Account.new
;TI")# => #<Account id: nil, email: nil>
;TI"account.id = 1
;TI"account.reload
;TI"q# Account Load (1.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT 1  [["id", 1]]
;TI"9# => #<Account id: 1, email: 'account@example.com'>
;T:@format0o;
;	[I"FAttributes are reloaded from the database, and caches busted, in ;TI":particular the associations cache and the QueryCache.;T@o;
;	[I"QIf the record no longer exists in the database ActiveRecord::RecordNotFound ;TI"Ois raised. Otherwise, in addition to the in-place modification the method ;TI"$returns +self+ for convenience.;T@o;
;	[I"TThe optional <tt>:lock</tt> flag option allows you to lock the reloaded record:;T@o;;	[I":reload(lock: true) # reload with pessimistic locking
;T;
0o;
;	[I"MReloading is commonly used in test suites to test something is actually ;TI"Mwritten to the database, or when some action modifies the corresponding ;TI"6row in the database but not the object in memory:;T@o;;	[I"!assert account.deposit!(25)
;TI"Lassert_equal 25, account.credit        # check it is updated in memory
;TI"Iassert_equal 25, account.reload.credit # check it is also persisted
;T;
0o;
;	[I"<Another common use case is optimistic locking handling:;T@o;;	[I"def with_optimistic_retry
;TI"
  begin
;TI"    yield
;TI"-  rescue ActiveRecord::StaleObjectError
;TI"    begin
;TI"0      # Reload lock_version in particular.
;TI"      reload
;TI"-    rescue ActiveRecord::RecordNotFound
;TI";      # If the record is gone there is nothing to do.
;TI"    else
;TI"      retry
;TI"
    end
;TI"  end
;TI"end;T;
0:
@fileI"%lib/active_record/persistence.rb;T:0@omit_headings_from_table_of_contents_below000[I"(options = nil);T@GFI"Persistence;TcRDoc::NormalModule00