diff options
author | Zachary Scott <e@zzak.io> | 2014-08-07 19:01:45 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-08-07 19:01:45 -0700 |
commit | f18552a8726f06fadefff550b079866c238bac8b (patch) | |
tree | 3f899b461be2aa5eb93efb5c0272a26e059bacd3 /activerecord | |
parent | fbe38c9e9d4fe9f82518e8ffc1d757459b0c5f1c (diff) | |
parent | 38b6b5db58457b5445d2c42298facf322136c3ae (diff) | |
download | rails-f18552a8726f06fadefff550b079866c238bac8b.tar.gz rails-f18552a8726f06fadefff550b079866c238bac8b.tar.bz2 rails-f18552a8726f06fadefff550b079866c238bac8b.zip |
Merge pull request #16384 from tomkadwill/improved_create_documentation
[ci skip] Added +object+ and +attributes+ to create! description for rdoc
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index f35865f54c..b89e081542 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -36,8 +36,11 @@ module ActiveRecord end end - # Creates an object just like Base.create but calls <tt>save!</tt> instead of +save+ - # so an exception is raised if the record is invalid. + # 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. + # + # 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. def create!(attributes = nil, &block) if attributes.is_a?(Array) attributes.collect { |attr| create!(attr, &block) } |