diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-10-07 12:07:56 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-10-07 12:07:56 -0300 |
commit | fbfc4ac298fe96ee8f57291143f0308f4b37b941 (patch) | |
tree | a972026d0570c5f32be86881a45b8726f1082307 /activerecord | |
parent | 3dc9c52ca9738b5c582e9aab6fb459d77d7dec2c (diff) | |
parent | 8764ef95dce3cbd0a58186e3cc1da90cc07862eb (diff) | |
download | rails-fbfc4ac298fe96ee8f57291143f0308f4b37b941.tar.gz rails-fbfc4ac298fe96ee8f57291143f0308f4b37b941.tar.bz2 rails-fbfc4ac298fe96ee8f57291143f0308f4b37b941.zip |
Merge pull request #17146 from divineforest/active-record-gsub-to-tr
Change `gsub` to `tr` where possible
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb index 34a555dfd4..815e8eb97f 100644 --- a/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb +++ b/activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb @@ -11,7 +11,7 @@ module ActiveRecord::Associations::Builder end def join_table - @join_table ||= [@lhs_class.table_name, klass.table_name].sort.join("\0").gsub(/^(.*[._])(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_") + @join_table ||= [@lhs_class.table_name, klass.table_name].sort.join("\0").gsub(/^(.*[._])(.+)\0\1(.+)/, '\1\2_\3').tr("\0", "_") end private diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 171a6f4391..48e82d28d9 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -63,7 +63,7 @@ module ActiveRecord # records, artists => artists_records # music_artists, music_records => music_artists_records def self.derive_join_table_name(first_table, second_table) # :nodoc: - [first_table.to_s, second_table.to_s].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_") + [first_table.to_s, second_table.to_s].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').tr("\0", "_") end module ClassMethods |