Skip to content

Commit

Permalink
Merge pull request rails#6056 from jeremyf/remove-deprecation-warning…
Browse files Browse the repository at this point in the history
…-due-to-reload

Removed deprecation warning for #find as a result of AR::Base#reload
  • Loading branch information
josevalim committed Apr 29, 2012
2 parents 8c2cf1a + d3ccdf6 commit 82029c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion activerecord/lib/active_record/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,13 @@ def reload(options = nil)
clear_aggregation_cache
clear_association_cache

fresh_object = self.class.unscoped { self.class.find(id, options) }
fresh_object =
if options.present? && options[:lock]
self.class.unscoped { self.class.lock.find(id) }
else
self.class.unscoped { self.class.find(id) }
end

@attributes.update(fresh_object.instance_variable_get('@attributes'))
@columns_hash = fresh_object.instance_variable_get('@columns_hash')

Expand Down

0 comments on commit 82029c7

Please sign in to comment.