Let's say you have put limits in place with either of the following:
class Order < ActiveRecord::Base
accepts_nested_attributes_for :line_items, limit: 3, allow_destroy: true
# OR
validates :line_items, length: { maximum: 3 }
end
Now let's say you go to edit an Order that already has 3 line items. If you remove one of the items, click the add link to add another item, and then submit the form, the validation will fail saying there are too many items. (Or if using the :limit option for accepts_nested_attributes_for you get ActiveRecord::NestedAttributes::TooManyRecords.
Let's say you have put limits in place with either of the following:
Now let's say you go to edit an Order that already has 3 line items. If you remove one of the items, click the add link to add another item, and then submit the form, the validation will fail saying there are too many items. (Or if using the :limit option for accepts_nested_attributes_for you get ActiveRecord::NestedAttributes::TooManyRecords.