Modifying Nested Resources Lab
Objectives
Implement nested resources for creation and modification
Overview
In this lab, we're going to be implementing nested resources for creating and editing songs through an artist.
Instructions
Using nested resources, set up routes and controller actions to create new
song
records through anartist
. Hint: Don't forget to update the strong parameters.Set up routes and controller actions to support editing a
song
as a nested resource of anartist
.Create a helper to display a drop-down list of artists if someone edits a song directly via
/songs/:id/edit
and to only display the artist's name if they are editing through nested routing. Name the helper methodartist_select
. Hint: You'll need to set a variable in the controller action to pass to the helper method as an argument along with asong
instance.Validate that new songs created for an artist via nested routing are created for valid artists, and redirect to
/artists
if not.Validate that songs being edited via nested routing have a valid artist. Redirect to
/artists
if not.Validate that songs being edited via nested routing are in the artist's
songs
collection. Redirect to/artists/:artist_id/songs
if not.Make sure all tests pass!
View Modifying Nested Resources Lab on Learn.co and start learning to code for free.
Last updated