2. Understand How Everything Works Together

Now that we understand how each individual component works in MVC, let's look at how everything works together.

The following diagram describes what happens behind the scenes in a Rails application:

image.png

Let's go through each step.

   Prefix Verb   URI Pattern               Controller#Action
     root GET    /                         ideas#index
    ideas GET    /ideas(.:format)          ideas#index
          POST   /ideas(.:format)          ideas#create
 new_idea GET    /ideas/new(.:format)      ideas#new
edit_idea GET    /ideas/:id/edit(.:format) ideas#edit
     idea GET    /ideas/:id(.:format)      ideas#show
          PATCH  /ideas/:id(.:format)      ideas#update
          PUT    /ideas/:id(.:format)      ideas#update
          DELETE /ideas/:id(.:format)      ideas#destroy

While you build your apps, always have this flow in mind. Once you become familiar with how the application works together, you'll have an easier time debugging and writing code.

Lesson list