Skip to content

Commit

Permalink
key habtm fixtures off table name
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Feb 12, 2011
1 parent 2b353ac commit 5b0695a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,11 @@ def insert_fixtures
fixtures.delete('DEFAULTS')

# track any join tables we need to insert later
habtm_fixtures = Hash.new do |h, habtm|
h[habtm] = HabtmFixtures.new(
habtm_fixtures = Hash.new do |h, path|
h[path] = HabtmFixtures.new(
@connection,
habtm.options[:join_table],
Fixtures.find_table_name(habtm.options[:join_table]), nil)
path,
Fixtures.find_table_name(path), nil)
end

rows = fixtures.map do |label, fixture|
Expand Down Expand Up @@ -655,7 +655,7 @@ def insert_fixtures
when :has_and_belongs_to_many
if (targets = row.delete(association.name.to_s))
targets = targets.is_a?(Array) ? targets : targets.split(/\s*,\s*/)
join_fixtures = habtm_fixtures[association]
join_fixtures = habtm_fixtures[association.options[:join_table]]

targets.each do |target|
join_fixtures["#{label}_#{target}"] = Fixture.new(
Expand Down

0 comments on commit 5b0695a

Please sign in to comment.