
Rails + Inertia + Svelte 5: Avatar Image/Color Selection Feature Implementation Struggles
This documents the problems encountered while implementing a pet profile avatar selection feature (image or color) on a Rails 8 + Inertia.js + Svelte 5 stack. Problem 1: Colors Were Not Stored in the DB Symptoms Looking at the initial code, pet card colors were displayed like this: const PET_COLORS = ['#f3caa1', '#b7ddf9', '#d3c8ff', '#c5d5f4', '#ffd9aa'] function petColor(index: number): string { return PET_COLORS[index % PET_COLORS.length] } Colors were determined by the order (index) in which pets were created. Since colors were not stored in the DB at all, even if a user changed a color, it would revert to the original on refresh. ...