Skip to content

Commit

Permalink
after saving the model, we set the primary key within the fixture has…
Browse files Browse the repository at this point in the history
…h, in case it was not explicitly specified in the fixture and was generated by an auto_increment / serial field
  • Loading branch information
Matthew Willson authored and jeremyevans committed Nov 17, 2008
1 parent b7db5cc commit da522b9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/fixture_dependencies.rb
Expand Up @@ -149,8 +149,13 @@ def use(record, loading = [], procs = {})
puts "#{spaces}#{record}.#{attr} = #{value.inspect}" if verbose > 2
obj.send("#{attr}=", value)
end

puts "#{spaces}saving #{record}" if verbose > 1

model_method(:model_save, mtype, obj)
# after saving the model, we set the primary key within the fixture hash, in case it was not explicitly specified in the fixture and was generated by an auto_increment / serial field
fixtures[model_name.to_sym][name.to_sym][model.primary_key.to_sym] ||= obj[model.primary_key.to_sym]

loading.pop
# Update the circular references
if procs[record]
Expand Down

0 comments on commit da522b9

Please sign in to comment.