
ActiveRecord Basics
Models, migrations, CRUD operations, validations, callbacks, scopes
1What is ActiveRecord in the context of Ruby on Rails?
What is ActiveRecord in the context of Ruby on Rails?
Câu trả lời
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.
2According to Rails conventions, what is the table name associated with a model named Article?
According to Rails conventions, what is the table name associated with a model named Article?
Câu trả lời
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.
3Which Rails command creates a new model with a migration?
Which Rails command creates a new model with a migration?
Câu trả lời
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.
What is a migration in Rails?
Which command runs all pending migrations?
+22 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Ruby on Rails khác
Ruby Basics
Ruby Object-Oriented Programming
Rails Fundamentals
Routing & Controllers
Views & ERB Templates
ActiveRecord Associations
Advanced ActiveRecord Queries
Rails Forms
Authentication & Authorization
Modern Asset Pipeline & Frontend
Rails API Mode
Testing with RSpec
ActiveJob & Background Jobs
ActionCable & WebSockets
ActionMailer
ActiveStorage
Caching Strategies
Advanced Migrations
Rails Engines & Modular Apps
Performance Optimization
Rails Design Patterns
Ruby Metaprogramming
Rails Security
GraphQL with Rails
Deployment & Production
Monitoring & Logging
Rails Upgrade Strategies
Nắm vững Ruby on Rails cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí