Skip to content

Commit

Permalink
Add underscore in front of internal method
Browse files Browse the repository at this point in the history
Since all models inherit from ActiveRecord::Base, any private
method added by the framework can clash with existing methods
in the models defined in the app. Since this is an internal method
that was just introduced and has a change of clashing with methods
in app (I just found one), better to define using the `_`.
  • Loading branch information
rafaelfranca committed Jan 6, 2021
1 parent df26bb0 commit 8a91423
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,9 @@ def reload(options = nil)
self.class.connection.clear_query_cache

fresh_object = if self.class.default_scopes?(all_queries: true) && !(options && options[:unscoped])
find_record(options)
_find_record(options)
else
self.class.unscoped { find_record(options) }
self.class.unscoped { _find_record(options) }
end

@attributes = fresh_object.instance_variable_get(:@attributes)
Expand Down Expand Up @@ -872,7 +872,7 @@ def touch(*names, time: nil)
end

private
def find_record(options)
def _find_record(options)
if options && options[:lock]
self.class.lock(options[:lock]).find(id)
else
Expand Down

0 comments on commit 8a91423

Please sign in to comment.