Now that we've built an online bookstore application in Ruby-on-Rails, it's time to serve our customers by building a book catalog of the store that they can use for browsing, viewing book details, searching for books, and finding out about new titles at a glance. This article, the first in a three-part series, is excerpted from chapter four of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
In this chapter, weíll work through setting up the basic functionality of a book catalog from the customerís perspective. Weíll build the chapter around four user stories where Jill, Georgeís book-hogging customer, plays the starring role.
For the Emporium book catalog, we will create a simple catalog page for the books, along with pages that display details for individual titles. The interface also will need a way to search for books by their titles and descriptions. We will use Ferret, a full-text search engine written in Ruby, to supply this functionality. Additionally, we will create a latest books page and RSS feed, so that Jill can follow whatís new at Emporium.
Getting the Book Catalog Requirements
If thereís one person keeping Emporium going, thatís Jill. Jill lives just a couple of blocks away from the store. When she rushes through the door with her plasma-TV-sized goggles, George knows that the day is saved.
However, Jillís health is not as it used to be. Her visits have gotten fewer and fewer lately. She would love to support George and buy a lot of new books, but itís just too much effort for her to come over daily. Jill is a smart lady, though, and sheís found out that this new thing called the Internet can work as an intermediary between her and her beloved book supply.
To make Jill a happy online customer, George comes up with four user stories for this sprint:
Browse books: Jill needs a way to browse the books in the shop. We will keep the list really simple at this point, just letting her shuffle through the supply and find out about new titles.
View book details: After browsing through titles in the first story or getting a list of matching titles in the second one, Jill needs a way to get specific information about a particular title. As a former librarian, she is obsessed about knowing even the most mundane details of every book she is thinking about buying.
Search books: Sometimes Jill finds out about an interesting topic and wants to know more about the subject. She needs to be able to write a few keywords and get a list of all the titles that match her search.
Get latest books: As a book addict, Jill needs a way to keep current about all new books. She would like to find out about new titles with a single look on the Emporium site. What would make her really happy, however, would be an RSS feed that she could follow on her shiny white iBook without even visiting the website. That would leave her more time for her real pleasure, perusing her precious tomes.
We will tackle these user stories in this chapter, one by one, using the already familiar TDD method.