I have a Message and Source model related as follows:
class Message < ActiveRecord::Base
has_many :sources
accepts_nested_attributes_for :sources, :allow_destroy => true, :reject_if => proc{|s| s[:href].blank?}
end
class Source < ActiveRecord::Base
belongs_to :outgoing_message
validates_presence_of :href
end
When I submit my form (built using form_for
and fields_for
) it filters out any new sources with blank hrefs. But what I want is for it to delete any existing sources whose hrefs have been set to blank. Is there a simple way to do that?