Rails Flashcards

1
Q

What types of associations can models have in RoR?

A

belongs_to
has_one
has_many
has_and_belongs_to_many
polimorphic
self joins

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

What’s a gem?

A

Packaged Ruby code, ready to be reused across projects.

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

What does MVC stand for?

A

Model View Controller

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

What’s the naming convention for models in Rails?

A

Singular, camel-cased nouns.

E.g. BookClub

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

What’s the naming convention for tables in Rails?

A

Pluralized, snake-cased nouns.

E.g. book_clubs

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

What’s the naming convention for controllers in Rails?

A

Pluralized, camel-cased nouns, suffixed with the term “Controller”.

E.g. BookClubsController

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

What’s a callback in the context of RoR?

A

It’s a method that gets called at certain moments of an object’s life cycle (e.g. when an Active Record object is created, saved, updated, deleted, validated, or loaded from the database).

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

What does ORM stand for?

A

Object Relational Mapping

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

What is Object Relational Mapping?

A

It is a technique that connects objects to tables in a relational database.

Using ORM, the properties and relationships of the objects in an application can be easily stored and retrieved from a database without writing SQL statements directly.

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

What’s Active Record?

A

Active Record is Ruby on Rails’ ORM framework.

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

What does “convention over configuration” mean?

A

Rails has a set of conventions (naming conventions and schema conventions); if you follow them, you’ll spare yourself from writing configuration code.

E.g. If your model is named “BookClub”, Rails will expect it to be related to a table named “book_clubs”; respecting that convention will keep your code free from configuration code.

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

What is “eager loading?

A

It’s a mechanism for loading associated records more efficiently.

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

Which methods does RoR provide for eager loading?

A

includes
preload
eager_load

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

What’s wrong with this code?

Project.where("name = '#{params[:name]}'")

A

It’s vulnerable to SQL injection.

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

How can you access sensitive credentials in RoR?

A

Rails.application.credentials

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