@workout.update(w) update_details(@workout.id) def update_details(workout_id) WorkoutDetail.where(workout_id: workout_id).delete_all p = params.permit(:id, :date, :kind, :impression, workout_details: [:id, :menu_kind, :times, :distance, details = p[:workout_details] details.each do |detail| rec = WorkoutDetail.new(detail) rec.workout_id = workout_id rec.save end