What is the purpose of the router in a Rails project?
The purpose of a router in a Rails project is to determine the actions that the project performs as a result of a client accessing a particular path.
What routes would be provided to you with the line resources :items
?
The full suite of RESTful actions: get "/items" => "items#index" get "/items/:id" => "items#show" get "/items/new" => "items#new" post "/items" => "items#create" get "/items/:id/edit" => "items#edit" put "/items/:id" => "items#update" delete "/items/:id" => "items#destroy"
What does root :to => "items#index"
represent? How would you access that route in a web app?
That code represents the action that the controller should rake when a user goes to the path "/". It sets the "home page" to index
.
What rake task is useful when looking at routes, and what information does it give you?
$ rake routes
How would you interpret this output: items GET /items(.:format) items#index
That output represents thef act that when a client goes to "/items" then he will be shown the index page.
What is one major similiarity between Rails routing + controllers and the Sinatra projects we've been building?
The first step in both Rails and Sinatra is to build CRUD functionality. Also the default paths that Rails builds are the same as the paths we have been using in our Sinatra projects.
What is one major difference between Rails routing + controllers and the Sinatra projects we've been building?
Rails can build the controllers and database relationships for us. Also the paths are assigned to actions in config/routes.rb
instead of in a server file.