diff options
Diffstat (limited to 'activerecord/lib/active_record/nested_attributes.rb')
-rw-r--r-- | activerecord/lib/active_record/nested_attributes.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 14af64c104..f0f88b120a 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -519,14 +519,15 @@ module ActiveRecord # larger than the limit. def check_record_limit!(limit, attributes_collection) if limit - limit = case limit - when Symbol - send(limit) - when Proc - limit.call - else - limit - end + limit = \ + case limit + when Symbol + send(limit) + when Proc + limit.call + else + limit + end if limit && attributes_collection.size > limit raise TooManyRecords, "Maximum #{limit} records are allowed. Got #{attributes_collection.size} records instead." |