diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-22 11:39:13 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-22 11:39:13 -0500 |
commit | 9c38cfc44afc2c8a9ab79801ff23c53f833d1085 (patch) | |
tree | 334774a68414f7cedeb420af0810d1724d8bc65a | |
parent | e0859e569c007cd108797883eec402c876b9e8a0 (diff) | |
download | rails-9c38cfc44afc2c8a9ab79801ff23c53f833d1085.tar.gz rails-9c38cfc44afc2c8a9ab79801ff23c53f833d1085.tar.bz2 rails-9c38cfc44afc2c8a9ab79801ff23c53f833d1085.zip |
add CollectionProxy#create documentation
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 33 |
1 files changed, 33 insertions, 0 deletions
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 @@ -218,6 +218,39 @@ module ActiveRecord # 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') + # # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1> + # + # person.pets.create([{name: 'Spook'}, {name: 'Choo-Choo'}]) + # # => [ + # # #<Pet id: 2, name: "Spook", person_id: 1>, + # # #<Pet id: 3, name: "Choo-Choo", person_id: 1> + # # ] + # + # person.pets.size # => 3 + # person.pets.count # => 3 + # + # person.pets.find(1, 2, 3) + # # => [ + # # #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>, + # # #<Pet id: 2, name: "Spook", person_id: 1>, + # # #<Pet id: 3, name: "Choo-Choo", person_id: 1> + # # ] + + ## # :method: concat # # :call-seq: |