Rails Cru Form_for Lab


  1. Build RESTful actions for index, show, new, create, edit, update
  2. Use form_for for all forms (no need to share forms or partials)
  3. Correctly redirect when needed
  4. Interlink between pages using route helpers


You've been tasked with building a Rails app called Beats by Rails, the app will need to have three separate models:

  • Songs

  • Artists

  • Genres

The data relationship will look something like this:

  • A song belongs to an artist

  • A song belongs to a genre

  • A genre has many songs

  • An artist has many songs

The tests are in the spec/features directory for each model. You will need to build in the ability to create, update, and show for each model. And for the song show page you need to have it display each of the song's genre and artist, and link to the respective genre and artist show pages.

The database tables should look like this (note each column type):

table "artists"
  string   "name"
  text     "bio"

table "genres"
  string   "name"

table "songs"
  string   "name"
  integer  "artist_id"
  integer  "genre_id"

Key notes to remember

  • You will need to use strong params

  • Don't worry about integrating drop down form elements for the genre and artist selections on the song form pages yet, simply enter in the ID in for each element

  • You can use the resource, model, migration, and controller generators, but do not use the scaffold generator Top Tip: Remember to use the --no-test-framework flag when generating models and controllers to avoid generating unnecessary testing frameworks!

View CRU with form_for Lab on Learn.co and start learning to code for free.

View CRU Rails Lab on Learn.co and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us