Frozen hash problem

I’d like to delete some records before saving them. I ran this
experiment:

before_save :prune_lab_datas

def prune_lab_datas
lab_datas.each do |lab_data|
lab_data.destroy
end
raise lab_datas.to_yaml
end

But nothing seems to be deleted in the hash:


  • &id001 !ruby/object:LabData
    attributes:
    created_at: 2010-03-21 22:16:06
    unit_id: “3”
    lab_id: “81”
    updated_at: 2010-03-21 22:16:06
    id: “184”
    lab_desc_id: “6”
    value: “29”
    attributes_cache: {}

    changed_attributes: {}

    errors: !ruby/object:ActiveRecord::Errors
    base: *id001
    errors: {}

And if I remove the “raise”, the controller throws a “can’t modify
frozen hash” error.

Any idea how I can remove records from the hash prior to saving?

TIA,
Craig