Skip to content

About

Modern Rails 8 + Hotwire photo gallery showcasing Turbo Frames, Stimulus, Tailwind CSS, Devise authentication, and server-rendered interactivity without a frontend framework.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Rails Hotwire Photo Gallery

A small Rails + Hotwire photo gallery application demonstrating server-rendered interactivity with Turbo Frames, Stimulus, and Tailwind CSS.

Users can authenticate, browse seeded photos, search by photographer, and like or unlike photos without full page reloads.

Features

  • Devise authentication with a seeded demo user
  • Photo import from db/photos.csv
  • Authenticated all-photos gallery
  • Server-side photographer search
  • Liked photos page
  • Like/unlike interactions with Turbo Frames
  • Immediate icon feedback with Stimulus
  • Database-backed like persistence
  • Unique database constraint so each user can like a photo once
  • Counter-cached like counts
  • Responsive card layout and accessible controls
  • RSpec coverage for models, requests, and the like/unlike system flow
  • GitHub Actions CI for specs, RuboCop, Brakeman, and gem audit

Screenshots

Sign in screen

Gallery screen

Tech Stack

  • Ruby 4.0.3
  • Rails 8.1.3
  • SQLite3
  • Devise
  • Turbo
  • Stimulus
  • Tailwind CSS
  • RSpec

Setup

Install dependencies and prepare the database:

bundle install
bin/rails db:prepare
bin/rails db:seed

Demo Credentials

Email: demo@example.com
Password: password123

The demo user and seeded photo data are created from db/seeds.rb. Photo records are imported from db/photos.csv and persisted in the database rather than read at runtime.

Running the Application

bin/dev

Then visit:

http://localhost:3000

Running the Test Suite

bundle exec rspec

Run quality checks:

bin/rubocop
bundle exec brakeman --no-pager --url-safe-methods safe_source_url
bin/bundler-audit check --update --database tmp/ruby-advisory-db

Implementation Notes

Authentication

Authentication is implemented with Devise using a seeded demo user so the project stays focused on gallery behavior.

Photo Importing

Photo data is imported from db/photos.csv during seeding and persisted in the database to avoid runtime CSV parsing.

Likes

Likes are modeled as a join table between users and photos.

A unique composite database index on [user_id, photo_id] ensures a user can only like a photo once while maintaining database-level integrity.

counter_cache keeps like counts cheap to render.

Hotwire Interactivity

The like/unlike UI is isolated within a Turbo Frame so only the relevant portion of the page updates after interaction.

Turbo handles server-driven UI replacement, while a lightweight Stimulus controller provides immediate visual feedback during interactions.

Testing

The application includes focused RSpec coverage for core business rules and user flows rather than exhaustive framework-level testing.

About

Modern Rails 8 + Hotwire photo gallery showcasing Turbo Frames, Stimulus, Tailwind CSS, Devise authentication, and server-rendered interactivity without a frontend framework.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages