|
1 | | -# README |
| 1 | +# Active Storage Test App |
2 | 2 |
|
3 | | -This README would normally document whatever steps are necessary to get the |
4 | | -application up and running. |
| 3 | +A Rails 8.1 application demonstrating Active Storage file uploads with Turbo Streams for real-time UI updates. |
5 | 4 |
|
6 | | -Things you may want to cover: |
| 5 | +## Features |
7 | 6 |
|
8 | | -* Ruby version |
| 7 | +- File upload with Active Storage |
| 8 | +- Real-time updates using Turbo Streams (no page refresh) |
| 9 | +- Display of uploaded files with download links |
| 10 | +- Visibility into Active Storage internals: |
| 11 | + - Attachments table (`active_storage_attachments`) |
| 12 | + - Blobs table (`active_storage_blobs`) |
9 | 13 |
|
10 | | -* System dependencies |
| 14 | +## Requirements |
11 | 15 |
|
12 | | -* Configuration |
| 16 | +- Ruby 3.x |
| 17 | +- Rails 8.1 |
| 18 | +- SQLite3 |
13 | 19 |
|
14 | | -* Database creation |
| 20 | +## Setup |
15 | 21 |
|
16 | | -* Database initialization |
| 22 | +```bash |
| 23 | +# Install dependencies |
| 24 | +bundle install |
17 | 25 |
|
18 | | -* How to run the test suite |
| 26 | +# Setup database |
| 27 | +bin/rails db:create db:migrate |
19 | 28 |
|
20 | | -* Services (job queues, cache servers, search engines, etc.) |
| 29 | +# Start the server |
| 30 | +bin/rails server |
| 31 | +``` |
21 | 32 |
|
22 | | -* Deployment instructions |
| 33 | +Visit `http://localhost:3000` to use the application. |
23 | 34 |
|
24 | | -* ... |
| 35 | +## Usage |
| 36 | + |
| 37 | +1. Enter a name for your upload |
| 38 | +2. Select a file |
| 39 | +3. Click "Upload" |
| 40 | + |
| 41 | +The file will be uploaded and all three tables will update instantly without page refresh: |
| 42 | +- **Uploaded Files** - Your Upload records with file download links |
| 43 | +- **Active Storage Attachments** - The join table linking records to blobs |
| 44 | +- **Active Storage Blobs** - File metadata (filename, content type, size, checksum) |
| 45 | + |
| 46 | +## Project Structure |
| 47 | + |
| 48 | +- `app/models/upload.rb` - Upload model with `has_one_attached :file` |
| 49 | +- `app/controllers/uploads_controller.rb` - Handles CRUD with Turbo Stream responses |
| 50 | +- `app/views/uploads/` - Views and Turbo Stream templates |
0 commit comments