Ruby on Rails

ActiveRecord Basics

Models, migrations, CRUD operations, validations, callbacks, scopes

25 preguntas de entrevista·
Junior
1

What is ActiveRecord in the context of Ruby on Rails?

Respuesta

ActiveRecord is the ORM (Object-Relational Mapping) component of Rails that represents the M (Model) in the MVC pattern. It allows manipulating database data as Ruby objects, establishing a correspondence between SQL tables and Ruby classes, and between columns and object attributes.

2

According to Rails conventions, what is the table name associated with a model named Article?

Respuesta

Rails uses a naming convention where the model name is singular and in CamelCase while the table name is plural and in snake_case. Thus, an Article model automatically corresponds to a table named articles. This convention allows Rails to infer associations without explicit configuration.

3

Which Rails command creates a new model with a migration?

Respuesta

The rails generate model command (or rails g model for short) simultaneously creates the model file in app/models, the corresponding migration file in db/migrate, and the test files. This ensures that the database structure and the Ruby model remain synchronized from the start.

4

What is a migration in Rails?

5

Which command runs all pending migrations?

+22 preguntas de entrevista

Domina Ruby on Rails para tu próxima entrevista

Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.

Empieza gratis