Action Controller Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does a Controller do

A

After routing has determined which controller to use for a request, your controller is responsible for making sense of the request and producing the appropriate output.

conventional RESTful applications, the controller will receive the request (this is invisible to you as the developer), fetch or save data from a model and use a view to create HTML output

A controller can thus be thought of as a middle man between models and views. It makes the model data available to the view so it can display that data to the user, and it saves or updates data from the user to the model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Name conventions for Controllers

A

The naming convention of controllers in Rails favors pluralization of the last word in the controller’s name, although it is not strictly required (e.g. ApplicationController). For example, ClientsController is preferable to ClientController, SiteAdminsController is preferable to SiteAdminController or SitesAdminsController, and so on.Following this convention will allow you to use the default route generators (e.g. resources, etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The two types of parameters are?

A

The query string is everything after “?” in the URL. The second type of parameter is usually referred to as POST data. This information usually comes from an HTML form which has been filled in by the user. It’s called POST data because it can only be sent as part of an HTTP POST request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
A

When this form is submitted, the value of params[:client] will be { “name” => “Acme”, “phone” => “12345”, “address” => { “postcode” => “12345”, “city” => “Carrot City” } }. Note the nested hash in params[:client][:address].

How well did you know this?
1
Not at all
2
3
4
5
Perfectly