Goal: Build basic Sinatra web applications with full CRUD functionality. Use RESTful naming conventions for routes.
form action
in a form determine in a Sinatra application?app.rb
routes are used to manage data between models (classes and methods) and views (.erb
files).So far our record store application isn't very useful. Once full CRUD functionality for Album
s has been added, include additional properties beside name
such as year
, genre
, artist
and so on. Once this is complete, consider the following challenges:
Album
by name. You will need an Album.search()
method to do this. Write a test for Album.search()
before you try to implement the rest of the functionality. Hint: You may want to review this lesson for ideas on how to write a .search()
method: Mapping and the Enumerable Module. Bonus points: use a regular expression for your search implementation.Album
s by name. You will need an Album.sort()
method.sold()
instance method to an Album
. This will move the Album
instance to a @@sold_albums
class variable. Implement the backend functionality first (along with testing). Once that's complete, add functionality to Sinatra to "buy" an Album
and view both available and sold Album
s.In Greek myth, the Sphinx guarded the gates of the city Thebes. Travelers could only pass the Sphinx if they correctly answered a riddle. Build an application where a user has to answer a series of the Sphinx's riddles in order to get into the city. Woe to the user that answers incorrectly! Your application should have a "success" page (for users that correctly answer all riddles) and a "failure" page if one of the riddles is answered incorrectly. You can find examples of the Sphinx’s riddles online or you can use your own. The focus of this project is to practice routing. Do not attempt the further explorations until you have a basic application with hard-coded riddles and complete routing first.
Riddle.random()
class method. This method does not need to be tested.
Lesson 24 of 37
Last updated July 28, 2022