Permalink
Browse files

after saving the model, we set the primary key within the fixture has…

…h, in case it was not explicitly specified in the fixture and was generated by an auto_increment / serial field
  • Loading branch information...
1 parent b7db5cc commit da522b9fe42e91c1865ddd27b046a24edb3770f5 Matthew Willson committed with Nov 13, 2008
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/fixture_dependencies.rb
View
5 lib/fixture_dependencies.rb
@@ -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]

0 comments on commit da522b9

Please sign in to comment.