When supplying a :limit option to accepts_nested_attributes_for, I found it a 
little bit surprising that records which are about to be destroyed count 
against the limit. From 
ActiveRecord::NestedAttributes#assign_nested_attributes_for_collection_association:

if options[:limit] && attributes_collection.size > options[:limit]
  raise TooManyRecords, "Maximum #{options[:limit]} records are allowed. Got 
#{attributes_collection.size} records instead."
end

It would be a trivial thing to count only those nested attributes which don't 
have the destroy flag set, or would be otherwise rejected.

A question for the group: Is the consensus, then, that since :limit is only 
intended to serve as a throttle on the number of changes sent in a single 
batch, it is pointless to incur the overhead of Array#select?

I can see the rationale,  since any real validation will need to take place at 
the model layer, anyway. Still, it does seem to, um, limit, the usefulness of 
the :limit option.

Thanks,
        Ernie

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to