refactor posts_controller, add attachment_helper, and passing api/posts tests