aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-22 11:52:14 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-22 11:52:14 -0500
commit7e5beca38fe64344eb8b97c9fba93096ff533543 (patch)
tree1da9bcf55d0e8ccd013c4decb17b0e54db9a2057 /activerecord/lib/active_record
parent9c38cfc44afc2c8a9ab79801ff23c53f833d1085 (diff)
downloadrails-7e5beca38fe64344eb8b97c9fba93096ff533543.tar.gz
rails-7e5beca38fe64344eb8b97c9fba93096ff533543.tar.bz2
rails-7e5beca38fe64344eb8b97c9fba93096ff533543.zip
add CollectionProxy#create! documentation
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 6e73ac79e2..6d001e8d10 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -249,6 +249,28 @@ module ActiveRecord
# # #<Pet id: 2, name: "Spook", person_id: 1>,
# # #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# # ]
+
+ ##
+ # :method: create!
+ #
+ # :call-seq:
+ # create!(attributes = {}, options = {}, &block)
+ #
+ # Like +create+, except that if the record is invalid will
+ # raise an exception.
+ #
+ # class Person
+ # has_many :pets
+ # end
+ #
+ # class Pet
+ # attr_accessible :name
+ # validates :name, presence: true
+ # end
+ #
+ # person.pets.create!(name: nil)
+ # # => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
+
##
# :method: concat