diff options
author | Zachary Scott <e@zzak.io> | 2014-08-07 19:05:21 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-08-07 19:05:21 -0700 |
commit | 30529dc00f96777c325dff496930f560fb9d59e9 (patch) | |
tree | 4470da3e2789f5e4d3463e81b40101f73053edf9 /activerecord | |
parent | f18552a8726f06fadefff550b079866c238bac8b (diff) | |
download | rails-30529dc00f96777c325dff496930f560fb9d59e9.tar.gz rails-30529dc00f96777c325dff496930f560fb9d59e9.tar.bz2 rails-30529dc00f96777c325dff496930f560fb9d59e9.zip |
Rephrase how we explain RecordInvalid exception in the context of
`#create!` regarding validations in contrast to the behavior of
`#create`. Also describe creating multiple objects using an array of
hashes as the +attributes+ parameter. [ci skip] /cc #16384
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index b89e081542..b5799d6bff 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -36,11 +36,13 @@ module ActiveRecord end end - # Creates an object (or multiple objects) and saves it to the database, if validations pass. - # Works like Base#create except that it raises a RecordInvalid error if validations fail. + # Creates an object (or multiple objects) and saves it to the database, + # if validations pass. Raises a RecordInvalid error if validations fail, + # unlike Base#create. # # The +attributes+ parameter can be either a Hash or an Array of Hashes. - # These Hashes describe the attributes on the objects that are to be created. + # These describe which attributes to be created on the object, or + # multiple objects when given an Array of Hashes. def create!(attributes = nil, &block) if attributes.is_a?(Array) attributes.collect { |attr| create!(attr, &block) } |