Edit works with function that replaces duplicate code in PostsController.