created a save function in the posts controller