- http://bad-reads.herokuapp.com/#/ Welcome to Bad Reads, a website thats allows you to find the baddest books out there. Bad reads can help you find some of the worst books out there. Then once you've found one you hate, leave a review!
- Ruby
- Javascript
- React
- Ruby on Rails
- Redux
- Node
- Bad Reads uses Ruby on Rails for its back end and React Redux for its front end. Jquery is used to get information from the backend to the frontend. JBuilder takes the place of Ruby on Rails's usual view files, and gets the information to React which actually handles the view. The Faker Gem is used to populate most of the website's information. The first nine books were put in manually but faker handled the other hundred to show scalability.
books.map(book => (
<BookIndexItem
book = {book}
key = {book.id}
requestAllReviews = {this.props.requestAllReviews}
/>
))
<td><Link to={`/books/${book.id}`}><img src={this.keyFinder(book.url)} alt="" className="book-photo" /></Link></td>
- Rate books and leave a review. The review can also be edited or deleted if left by the current user.
{this.props.currentUser === review.user_id ?
<div className='review-edit-delete'>
<Link to={`/books/review/${review.id}/edit`} className='review-delete'>Edit</Link>
<button onClick={() => this.handleDelete(this.props.bookId, review)}
className='review-delete'>Delete</button>
</div>
:''}
-
The average rating of each book is acheived with this function. Then value is passed to the stars component which then selects the correct star.
avgRating() {
let reviews = this.props.book.reviews
if (reviews) {
let count = 0;
let length = reviews.length;
reviews.map(review => {
count += review.rating
}
);
let num = parseFloat(count / length);
return num.toFixed(2)
}
else { return null }
}
```
* A feature that I am proud of is the review form. It is a partial and took a lot of work because the information it needs is different on create and edit. The end result was dryier code that works as intended.