Module: ActiveRecord::ModelSchema
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/model_schema.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.derive_join_table_name(first_table, second_table) ⇒ Object
Derives the join table name for
first_table
andsecond_table
.
Methods included from ActiveSupport::Concern
append_features, class_methods, extended, included, prepend_features, prepended
Class Method Details
.derive_join_table_name(first_table, second_table) ⇒ Object
Derives the join table name for first_table
and second_table
. The table names appear in alphabetical order. A common prefix is removed (useful for namespaced models like Music::Artist and Music::Record):
artists, records => artists_records
records, artists => artists_records
music_artists, music_records => music_artists_records
183 184 185 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/model_schema.rb', line 183 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').tr("\0", "_") end |