diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-06 11:36:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-06 11:36:02 -0700 |
commit | cd85615046a409f84e7a96900c5fb4037d3bc2e1 (patch) | |
tree | b63df16fb50f487545d6ca1b3dbbb38b817d5ff2 | |
parent | 59ba85fa5e31965130632d0c90c508693b14b086 (diff) | |
download | rails-cd85615046a409f84e7a96900c5fb4037d3bc2e1.tar.gz rails-cd85615046a409f84e7a96900c5fb4037d3bc2e1.tar.bz2 rails-cd85615046a409f84e7a96900c5fb4037d3bc2e1.zip |
make the duplicate code more similar
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index f185581dda..5b4d87df7a 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -648,9 +648,12 @@ module ActiveRecord if (targets = row.delete(association.name.to_s)) targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/) table_name = association.join_table + lhs_key = association.through_reflection.foreign_key + rhs_key = association.foreign_key + rows[table_name].concat targets.map { |target| - { association.through_reflection.foreign_key => row[primary_key_name], - association.foreign_key => ActiveRecord::FixtureSet.identify(target) } + { lhs_key => row[primary_key_name], + rhs_key => ActiveRecord::FixtureSet.identify(target) } } end end @@ -660,9 +663,12 @@ module ActiveRecord if (targets = row.delete(association.name.to_s)) targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/) table_name = association.join_table + lhs_key = association.foreign_key + rhs_key = association.association_foreign_key + rows[table_name].concat targets.map { |target| - { association.foreign_key => row[primary_key_name], - association.association_foreign_key => ActiveRecord::FixtureSet.identify(target) } + { lhs_key => row[primary_key_name], + rhs_key => ActiveRecord::FixtureSet.identify(target) } } end end |