aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-01 01:30:44 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-01 01:34:49 +0900
commit42d20e8de55eff9462fa55afdf98c950f7b0709d (patch)
treeb9eac1bdb0cc8424bd9e31089b4cdd2c244bd030 /activerecord/lib/active_record
parent7c3da6e0030aa080fcb89af58b094ed50d861a44 (diff)
downloadrails-42d20e8de55eff9462fa55afdf98c950f7b0709d.tar.gz
rails-42d20e8de55eff9462fa55afdf98c950f7b0709d.tar.bz2
rails-42d20e8de55eff9462fa55afdf98c950f7b0709d.zip
Revert "Merge pull request #33729 from kddeisz/plural-automatic-inverse"
This reverts commit ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e, reversing changes made to 3d2caab7dc92a13d4dd369678d5b4ce659df8e52. Reason: 7c3da6e0030aa080fcb89af58b094ed50d861a44
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/reflection.rb20
1 files changed, 5 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index b2110f727c..6d2f75a3ae 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -612,21 +612,9 @@ module ActiveRecord
# returns either +nil+ or the inverse association name that it finds.
def automatic_inverse_of
- return unless can_find_inverse_of_automatically?(self)
+ if can_find_inverse_of_automatically?(self)
+ inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name.demodulize).to_sym
- inverse_name_candidates =
- if options[:as]
- [options[:as]]
- else
- active_record_name = active_record.name.demodulize
- [active_record_name, ActiveSupport::Inflector.pluralize(active_record_name)]
- end
-
- inverse_name_candidates.map! do |candidate|
- ActiveSupport::Inflector.underscore(candidate).to_sym
- end
-
- inverse_name_candidates.detect do |inverse_name|
begin
reflection = klass._reflect_on_association(inverse_name)
rescue NameError
@@ -635,7 +623,9 @@ module ActiveRecord
reflection = false
end
- valid_inverse_reflection?(reflection)
+ if valid_inverse_reflection?(reflection)
+ return inverse_name
+ end
end
end