module ActiveRecord::ModelSchema

def self.derive_join_table_name(first_table, second_table) # :nodoc:

:nodoc:
music_artists, music_records => music_artists_records
records, artists => artists_records
artists, records => artists_records

(useful for namespaced models like Music::Artist and Music::Record):
table names appear in alphabetical order. A common prefix is removed
Derives the join table name for +first_table+ and +second_table+. The
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