Ladies and Gentlemen . . . Mr. C.V.!
On his 1960 album Giant Steps, saxophonist John Coltrane included a song called “Mr. P.C.” Dedicated to bassist Paul Chambers, the uptempo blues tune was widely covered by other artists. But could John Coltrane code? No, he couldn’t! Could he make a rails app? Not a chance!

That’s why I’d like to introduce you to Mr. C.V., or Models Routes Controllers Views. Mr. C.V. can do what John Coltrane couldn’t: make a rails app! When you’re stuck on how to get started, just ask Mr. C.V. for directions: Models Routes Controllers Views.
Okay, let’s get a basic rails app going. Let’s do one inspired by John Coltrane.
Jump in the terminal and do: rails new coltrane. Then cd coltrane, and code . to open it up.
Let’s make two models, Musician and Saxophone. Do: rails g model musician name:string genre:string. And do: rails g model saxophone type:string. This will create the models AND the migrations. Amazing!
Let’s make the relationships next, in the models. A musician has many saxophones. But a saxophone belongs to a musician.

Okay, we’ve done the M! Let’s move to Routes and finish the Mr.! Go to config/routes and do:
resources :musicians, only: [:index, :show]
resources :saxophones, only: [:index, :show]
Since we’re just building a basic app right now, we only need the Index and Show views. But that’s the R! We’ve completed Mr.! But don’t forget to make some seeds. For instance:
Musician.create(name: “John Coltrane”, genre: “jazz”)
Musician.create(name: “Eric Dolphy”, genre: “jazz”)
Then rails db:migrate and rails db:seed!
Now we can start the C.V. part. Controllers and Views! Do: rails g controller musicians and rails g controller saxophones. Then put index and show methods in the controllers.
Now for the Views! We’re almost there. Make an index file and a show file for the musician views. Throw a little html into those files:

Then fire up localhost:3000 and see what you’ve got!

