instance method join_table_name

Ruby on Rails 3.0.20

Since v2.2.3 Last seen in v3.0.20 Private

Available in: v2.2.3 v2.3.18 v3.0.20

Signature

join_table_name(first_table_name, second_table_name)

Generates a join table name from two provided table names. The names in the join table names end up in lexicographic order.

join_table_name("members", "clubs")         # => "clubs_members"
join_table_name("members", "special_clubs") # => "members_special_clubs"

Parameters

first_table_name req
second_table_name req
Source
# File activerecord/lib/active_record/associations.rb, line 1425
        def join_table_name(first_table_name, second_table_name)
          if first_table_name < second_table_name
            join_table = "#{first_table_name}_#{second_table_name}"
          else
            join_table = "#{second_table_name}_#{first_table_name}"
          end

          table_name_prefix + join_table + table_name_suffix
        end

Defined in activerecord/lib/active_record/associations.rb line 1425 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Associations::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close