Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Removed deprecation warning for #find as a result of AR::Base#reload #6052

Merged
merged 0 commits into from

3 participants

@jeremyf

DEPRECATION WARNING: Passing options to #find is deprecated. Please
build a scope and then call #find on it.

activerecord/lib/active_record/persistence.rb
@@ -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] || options['lock'])
@josevalim Owner

Do we really need to check for both string and symbol keys?

@jeremyf
jeremyf added a note

When I ran the test suite, there were only references to :lock, so I could update the commit.

However, I don't know if the method is receiving a hash with indifferent access.

As far as I could tell the only options passed in are :lock => , and I didn't see :lock => false.

@josevalim Owner

So let's leave it with just the :lock call. We are not supposed to accept both ways unless explicitly documented. Also, can you indent the if block?

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jeremyf jeremyf merged commit 6bea191 into from
@jeremyf

I think I may have bungled my git-fu; I've since created a separate pull request at #6056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Sorry, commit information is not available for this pull request.

Something went wrong with that request. Please try again.