Permalink
Browse files

Implemented `build` method in HasMany association

  • Loading branch information...
1 parent aa91f23 commit 997935084f082acc0e4600494848276fd73c7bce @serebryakov serebryakov committed May 28, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/lib/associations/has_many.rb
@@ -81,8 +81,12 @@ def find(*args)
# have been instantiated with attributes and linked to this object
# through a foreign key, but have not yet been saved.
##
- def build
- raise NotImplementedError, '`build` not yet implemented' # TODO
+ def build(*attributes)
+ objs = attributes.map do |atts|
+ @association.new(atts)
+ end
+ self.push(*objs)
+ objs
end
##

0 comments on commit 9979350

Please sign in to comment.