
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?
Respuesta
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?
Respuesta
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?
Respuesta
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 preguntas de entrevista
Otros temas de entrevista Ruby on Rails
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
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