Probably could be `@template.media.each do { |m| m.key = "replaced_#{m.key}" unless m.new_record? }`