Permalink
Browse files

Fix issues on ruby 1.9 due to lack of String#each

*_to_many associations can have singular values, indicating they
only have a single associated object, so work with both
single objects and arrays of objects correctly.
  • Loading branch information...
1 parent 85bdd58 commit 889e09649ef040f9ce7e1b351d155ef78fa9f88e @jeremyevans committed Jun 4, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/fixture_dependencies.rb
@@ -190,8 +190,8 @@ def use(record, loading = [], procs = {})
use(dep_name, loading, procs)
value = get(dep_name)
end
- elsif
- many_associations << [attr, reflection, model_method(:reflection_type, mtype, reflection) == :has_one ? [value] : value]
+ else
+ many_associations << [attr, reflection, value]
next
end
end
@@ -213,7 +213,7 @@ def use(record, loading = [], procs = {})
end
# Update the has_many and habtm associations
many_associations.each do |attr, reflection, values|
- values.each do |value|
+ Array(values).each do |value|
dep_name = "#{model_method(:reflection_class, mtype, reflection).name.underscore}__#{value}".to_sym
rtype = model_method(:reflection_type, mtype, reflection) if verbose > 1
if dep_name == record

0 comments on commit 889e096

Please sign in to comment.