Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问clear审计通过

active-storage-setup活动存储设置

Agent Skill

active-storage-setup 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

533

周安装

22

GitHub Stars

520

下载量

174
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:active-storage-setup(活动存储设置)
来源仓库:https://github.com/thibautbaissac/rails_ai_agents
仓库路径:skills/active-storage-setup
安装命令:
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill active-storage-setup
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/thibautbaissac/rails_ai_agents --skill active-storage-setup

简介

该技能指导 Rails 8 项目中 Active Storage 的配置与使用,支持云存储与本地磁盘方案。

  • 适用于文件上传、图片变体生成及浏览器直传功能的快速搭建需求。
  • 涵盖 S3、GCS、Azure 等主流云服务商接入配置与安全凭证管理。
  • 可通过 image_processing gem 实现缩略图裁剪与尺寸调整等图像处理操作。
  • 需运行 bin/rails active_storage:install 完成数据库迁移方可启用功能。

SKILL.md

Active Storage Setup for Rails 8

Overview

Active Storage handles file uploads in Rails:

  • Cloud storage (S3, GCS, Azure) or local disk
  • Image variants (thumbnails, resizing)
  • Direct uploads from browser
  • Polymorphic attachments

Quick Start

# Install Active Storage (if not already)
bin/rails active_storage:install
bin/rails db:migrate

# Add image processing
bundle add image_processing

Configuration

Storage Services

# config/storage.yml
local:
  service: Disk
  root: <%= Rails.root.join("storage") %>

test:
  service: Disk
  root: <%= Rails.root.join("tmp/storage") %>

amazon:
  service: S3
  access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
  secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
  region: eu-west-1
  bucket: <%= Rails.application.credentials.dig(:aws, :bucket) %>

google:
  service: GCS
  credentials: <%= Rails.root.join("config/gcs-credentials.json") %>
  project: my-project
  bucket: my-bucket

Environment Config

# config/environments/development.rb
config.active_storage.service = :local

# config/environments/production.rb
config.active_storage.service = :amazon

Model Attachments

Single Attachment

# app/models/user.rb
class User < ApplicationRecord
  has_one_attached :avatar

  # With variant defaults
  has_one_attached :avatar do |attachable|
    attachable.variant :thumb, resize_to_limit: [100, 100]
    attachable.variant :medium, resize_to_limit: [300, 300]
  end
end

Multiple Attachments

# app/models/event.rb
class Event < ApplicationRecord
  has_many_attached :photos

  has_many_attached :documents do |attachable|
    attachable.variant :preview, resize_to_limit: [200, 200]
  end
end

TDD Workflow

Active Storage Progress:
- [ ] Step 1: Add attachment to model
- [ ] Step 2: Write model spec for attachment
- [ ] Step 3: Add validations (type, size)
- [ ] Step 4: Create upload form
- [ ] Step 5: Handle in controller
- [ ] Step 6: Display in views
- [ ] Step 7: Test upload flow

Testing Attachments

See testing.md for model specs, factory traits, and request specs.

Key patterns:

  • Use fixture_file_upload in request specs
  • Define :with_avatar factory traits using after(:build)
  • Test be_attached and variant presence in model specs

Validations

Use the active_storage_validations gem for declarative validation, or write manual validate methods. See validations.md for both approaches.

# Gemfile
gem 'active_storage_validations'

Image Variants

Define named variants on the model attachment using resize_to_fill, resize_to_limit, or resize_to_cover. See variants-and-views.md for variant operations, view helpers, and form examples.

Controller and Service Handling

  • Permit :avatar for single uploads, photos: [] for multiple
  • Use purge to remove attachments, with optional Turbo Stream response
  • Use rails_blob_path or send_data for downloads

See controller-and-service.md for full controller examples, service methods, direct uploads setup, and performance tips.

Checklist

  • Active Storage installed and migrated
  • Storage service configured
  • Image processing gem added (if using variants)
  • Attachment added to model
  • Validations added (type, size)
  • Variants defined
  • Controller permits attachment params
  • Form handles file upload
  • Tests written for attachments
  • Direct uploads configured (if needed)

References

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.68%
按下载量换算46

OpenCode

22.58%
按下载量换算39

Codex

18.83%
按下载量换算33

Antigravity

12.44%
按下载量换算22

windsurf

8.43%
按下载量换算15

trae

3.94%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills