Your goal in this lab is to create a thorough CRUD interface for one model, the
Song
.
Songs have the following attributes and limitations:
title
, astring
- Must not be blank
- Cannot be repeated by the same artist in the same year
released
, aboolean
describing whether the song was ever officially released.- Must be
true
orfalse
- Must be
release_year
, aninteger
- Optional if
released
isfalse
- Must not be blank if
released
istrue
- Must be less than or equal to the current year
- Optional if
artist_name
, astring
- Must not be blank
genre
, astring
Use the resource
generator, not the scaffold
generator
-
Define a model with validations for
Song
-
Define all RESTful routes for songs
-
Build views that connect to each other using route helpers.
-
Use
button_to
to build forms with pre-fill and error list features. (Hint: Try using a partial to cut down on copy/pasting!) -
Allow deleting songs with a link, using
link_to
. Check out the official documentation for additional info including setting themethod:
to:delete
. -
Be sure to include your new assets in
application.html.erb
-
Use strong parameters in your POST/PATCH controller actions.
-
Set the root route to the song index.
-
Render the list of songs in an HTML table.
View CRUD With Validations Lab on Learn.co and start learning to code for free.