
ActiveStorage
File uploads, attachments, has_one_attached, has_many_attached, S3, variants, previews
1Which command should be used to install ActiveStorage in a Rails application?
Which command should be used to install ActiveStorage in a Rails application?
Câu trả lời
The rails active_storage:install command generates the necessary migrations to create the active_storage_blobs and active_storage_attachments tables. These tables store metadata about uploaded files. After installation, run rails db:migrate to apply the migrations to the database.
2Which macro should be used to attach a single file (avatar) to a User model?
Which macro should be used to attach a single file (avatar) to a User model?
Câu trả lời
The has_one_attached macro allows attaching a single file to a model. It automatically creates the methods avatar, avatar=, avatar.attach, avatar.attached? and avatar.purge. For multiple files, use has_many_attached instead.
3Which macro should be used to attach multiple files (documents) to a Project model?
Which macro should be used to attach multiple files (documents) to a Project model?
Câu trả lời
The has_many_attached macro allows attaching multiple files to a model. It creates the methods documents, documents.attach, documents.attached? and documents.purge. Files are stored in a collection and can be added or removed individually.
Which method should be used to check if a file is already attached to a record?
In which configuration file should the default storage service (local, S3, etc.) be defined?
+17 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
ActiveRecord Basics
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
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í