diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-06-20 01:58:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-06-20 01:58:36 +0000 |
commit | 722e0b6a8bb62226437e466b5a98356d026b05f5 (patch) | |
tree | 63aebf36e9d2dcc63f35210b764b1af061178073 /activerecord/lib/active_record/base.rb | |
parent | e4254939aa8abb7a18f65e95cafaa2f37cbfa754 (diff) | |
download | rails-722e0b6a8bb62226437e466b5a98356d026b05f5.tar.gz rails-722e0b6a8bb62226437e466b5a98356d026b05f5.tar.bz2 rails-722e0b6a8bb62226437e466b5a98356d026b05f5.zip |
r4664@asus: jeremy | 2006-06-19 18:55:36 -0700
Use the #lock method to obtain a row lock on a single record. Simply reloads the record with :lock => true.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4462 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 55befcd29f..da4ade6e36 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1541,10 +1541,13 @@ module ActiveRecord #:nodoc: end # Reloads the attributes of this object from the database. - def reload + # The optional options argument is passed to find when reloading so you + # may do e.g. record.reload(:lock => true) to reload the same record with + # an exclusive row lock. + def reload(options = nil) clear_aggregation_cache clear_association_cache - @attributes.update(self.class.find(self.id).instance_variable_get('@attributes')) + @attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes')) self end |