Skip to content

Instantly share code, notes, and snippets.

@EliseFitz15
Last active December 17, 2015 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EliseFitz15/f3c8ac5b589ae615ef17 to your computer and use it in GitHub Desktop.
Save EliseFitz15/f3c8ac5b589ae615ef17 to your computer and use it in GitHub Desktop.
SC-6-practice.md

Practice Rails MVC and Nested Routing

Create a Rails application that allows users to view books. The application must satisfy the following criteria:

  • A book has to have a title, author, and isbn code. It can optionally have a description and a genre.
  • Visiting the /books path should contain a list of books.
  • Visiting the /books/new path should display a form for adding a new book.
  • If a book is saved I'm redirected to to /books and should new the book name I've added, if it is not I'm left on the /books/new page and displayed an error.
  • Visiting the /books/5 path should show the book details for a book with ID = 5.
  • Visiting the root path should display a list of all books.

Once these criteria have been met, add the ability for users to review books. For this challenge assume all books and reviews are added anonymously. The application must satisfy the following criteria:

  • A book can have many reviews. Each review must contain a rating between only 1 and 5, a body, and a timestamp for when it was created.
  • If a review is saved, I'm redirected to the books/5 path, if it is not saved, I should be left on the new review form page and render errors associated with the review.
  • Visiting the /books/5/reviews/new should display a form for creating a new review for a book with ID = 5.
  • Visiting the /books/5 path should also include all reviews for a book with ID = 5.

For additional practice create some acceptance tests that allow the user to complete the following stories.(Hint these should be passing according the above criteria):

  • Viewing a list of books
  • Adding a new book through a form
  • Viewing the details of a specific book
  • Adding a review for a specific book only shows on the details page for that book

If you need to get rspec set up in your app check here for reference

  • Add to Gemfile gem 'rspec-rails, '~> 3.0'
  • rails generate rspec:install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment