kmarks2013 / rails-cru-form_for-lab-dumbo-web-080519

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CRU with form_for Lab

Objectives

  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

Instructions

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:

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.

About

License:Other


Languages

Language:Ruby 83.3%Language:HTML 13.1%Language:CSS 1.8%Language:JavaScript 1.8%