diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-27 10:16:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-27 10:16:14 -0800 |
commit | 69816a830bb2f5c0df1f8f4a6f97fd951e5edb9d (patch) | |
tree | 37dc9c60be1bce9e02b597901d048108cb69ac37 /activerecord/lib/active_record/migration/join_table.rb | |
parent | a8da5d82fd2b87c1a34d8ede5343219a82be40bc (diff) | |
parent | 080bd83df9ee96845370a73d6152bbe5f231f618 (diff) | |
download | rails-69816a830bb2f5c0df1f8f4a6f97fd951e5edb9d.tar.gz rails-69816a830bb2f5c0df1f8f4a6f97fd951e5edb9d.tar.bz2 rails-69816a830bb2f5c0df1f8f4a6f97fd951e5edb9d.zip |
Merge pull request #4726 from rafaelfranca/create_join_table
Add create_join_table migration helper to create HABTM join tables
Diffstat (limited to 'activerecord/lib/active_record/migration/join_table.rb')
-rw-r--r-- | activerecord/lib/active_record/migration/join_table.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/migration/join_table.rb b/activerecord/lib/active_record/migration/join_table.rb new file mode 100644 index 0000000000..01a580781b --- /dev/null +++ b/activerecord/lib/active_record/migration/join_table.rb @@ -0,0 +1,17 @@ +module ActiveRecord + class Migration + module JoinTable #:nodoc: + private + + def find_join_table_name(table_1, table_2, options = {}) + options.delete(:table_name) { join_table_name(table_1, table_2) } + end + + def join_table_name(table_1, table_2) + tables_names = [table_1, table_2].map(&:to_s).sort + + tables_names.join("_").to_sym + end + end + end +end |