Midterm Qs : Rails MVC Flashcards

1
Q

Know about MVC architecture and what it aims to do.

A

-consists of three main types of code: Models, Views, and Controllers
-every user action that can be performed on a web page—clicking a link or button, submitting a fill-in form, or using drag-and-drop—is eventually handled by some controller action, which will consult the model(s) as needed to obtain information and generate a view in response.
-is one of a family of patterns for structuring interactive applications.
-distinguishes models that implement business logic, views that present information to the user and allow the user to interact with the app, and controllers that mediate the interaction between views and models.

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

What is a model?

A

-the main data managed by the app
-stored in a relational database using the Active Record design pattern

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

What is a view?

A

-allow users to see and interact with the data
-serve as the interface between the system’s users and its data
-use the Template View pattern to create HTML and JSON representations of the app’s models.

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

What is a controller?

A

-mediate interaction between the views and models
-follow REST in which each controller action describes a single self-contained operation on one of the app’s resources

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

The (a) blank subsystem is responsible for mapping incoming HTTP requests to (b) and extracting any required or optional parameters.

A

(a)Routing Routes
(b)Controller actions

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

Which type of variables are accessible to views?

A

instance variables

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

What does a scaffold do?

A

easily creates a model view and controller for quick development

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

Know where to find models, views, and controllers in the Rails directory structure.

A

app/models/model.rb
app/views/models/action.rb
app/controllers/model_controller.rb

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

Know which file to find the routes in a Rails project.

A

config/routes.rb

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

If you generate scaffold for a resource Movie, what is the name of the controller and which file is it located at?

A

app/controllers/movies_controller.rb

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

If you generate a scaffold for a resource Movie, what is the name of the model and which file is it located at?

A

movies.rb

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

If you generate a scaffold for a resource Movie, what is the name of the database table created?

A

Movies

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

What is ActiveRecord and what power does it give Rails models?

A

-(ActiveRecord)refers to the code module that instantiates the pattern in the Rails framework
-(Active Record)allows Rails models to know how to C,R,U,D themselves in the database without the developer knowing the required SQL commands to do it.
-uses convention over configuration to infer database table names from the names of model classes and to infer the names and types of the columns(attributes) associated with a given kind of model.
-can query and filter.
-The power for Rails models is that it becomes resources whose instances are stored in a relational database.

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

Where does Rails keep the description of the structure of your database?

A

Active Record

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