From 9c38cfc44afc2c8a9ab79801ff23c53f833d1085 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:39:13 -0500 Subject: add CollectionProxy#create documentation --- .../active_record/associations/collection_proxy.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 33779a9ad7..6e73ac79e2 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -217,6 +217,39 @@ module ActiveRecord # person.pets.size # => 5 # size of the collection # person.pets.count # => 0 # count from database + ## + # :method: create + # + # :call-seq: + # create(attributes = {}, options = {}, &block) + # + # Returns a new object of the collection type that has been instantiated with + # attributes, linked to this object and that has already been saved (if it + # passed the validations). + # + # class Person + # has_many :pets + # end + # + # person.pets.create(name: 'Fancy-Fancy') + # # => # + # + # person.pets.create([{name: 'Spook'}, {name: 'Choo-Choo'}]) + # # => [ + # # #, + # # # + # # ] + # + # person.pets.size # => 3 + # person.pets.count # => 3 + # + # person.pets.find(1, 2, 3) + # # => [ + # # #, + # # #, + # # # + # # ] + ## # :method: concat # -- cgit v1.2.3