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
songrecords through anartist. Hint: Don't forget to update the strong parameters.Set up routes and controller actions to support editing a
songas 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/editand 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 asonginstance.Validate that new songs created for an artist via nested routing are created for valid artists, and redirect to
/artistsif not.Validate that songs being edited via nested routing have a valid artist. Redirect to
/artistsif not.Validate that songs being edited via nested routing are in the artist's
songscollection. Redirect to/artists/:artist_id/songsif not.Make sure all tests pass!
View Modifying Nested Resources Lab on Learn.co and start learning to code for free.
Last updated