https://github.com/coderhs/rails-storage-example
Example Rails app with activestorage
https://github.com/coderhs/rails-storage-example
Last synced: about 2 months ago
JSON representation
Example Rails app with activestorage
- Host: GitHub
- URL: https://github.com/coderhs/rails-storage-example
- Owner: coderhs
- Created: 2025-11-19T16:28:46.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-11-23T03:32:36.000Z (4 months ago)
- Last Synced: 2025-11-23T05:21:44.047Z (4 months ago)
- Language: HTML
- Size: 77.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Active Storage Test App
A Rails 8.1 application demonstrating Active Storage file uploads with Turbo Streams for real-time UI updates.
## Features
- File upload with Active Storage
- Real-time updates using Turbo Streams (no page refresh)
- Display of uploaded files with download links
- Visibility into Active Storage internals:
- Attachments table (`active_storage_attachments`)
- Blobs table (`active_storage_blobs`)
## Requirements
- Ruby 3.x
- Rails 8.1
- SQLite3
## Setup
```bash
# Install dependencies
bundle install
# Setup database
bin/rails db:create db:migrate
# Start the server
bin/rails server
```
Visit `http://localhost:3000` to use the application.
## Usage
1. Enter a name for your upload
2. Select a file
3. Click "Upload"
The file will be uploaded and all three tables will update instantly without page refresh:
- **Uploaded Files** - Your Upload records with file download links
- **Active Storage Attachments** - The join table linking records to blobs
- **Active Storage Blobs** - File metadata (filename, content type, size, checksum)
## Project Structure
- `app/models/upload.rb` - Upload model with `has_one_attached :file`
- `app/controllers/uploads_controller.rb` - Handles CRUD with Turbo Stream responses
- `app/views/uploads/` - Views and Turbo Stream templates