cocoon
cocoon copied to clipboard
Empty object being created even if owning object has :reject_if => :all_blank set
Exactly as it says
I have PurchaseDetails
class PurchaseDetail < ActiveRecord::Base
has_many :purchases
accepts_nested_attributes_for :purchases, :reject_if => :all_blank, :allow_destroy => true
end
This is still allowing an extra empty object to be created.
You have to show some more information @kaizenx. Maybe you have some hidden fields in your form? Do you fill in default fields from within your controller? Do you have a select-dropdown which automatically selects the first value? What is posted to the controller? The code you show is pure rails code, so for me it is hard to guess the relation with cocoon now.
Or, if that is your question, I have tested in my own code before and can confirm this should work.