rails-active-storage
Installation
SKILL.md
Rails Active Storage
Attachment Types
- Use
has_one_attached :avatarfor single file fields - Use
has_many_attached :documentsfor collections - Prefer descriptive names (e.g.,
profile_pictureoverimage)
Validations
- Active Storage does not include file validations out of the box
- Validate presence, content type, and file size manually using custom validation methods
- Check
avatar.attached?for presence andavatar.blob.content_typefor format
Image Processing
- Use
variant(resize_to_limit: [...])for resizing - Guard with
representable?before calling.varianton non-image blobs - Always check
attached?before rendering