Skip to content

Fix UserDashboard id field type after UUID migration#225

Merged
edimossilva merged 2 commits into
mainfrom
fix-user-dashboard-uuid-id
May 7, 2026
Merged

Fix UserDashboard id field type after UUID migration#225
edimossilva merged 2 commits into
mainfrom
fix-user-dashboard-uuid-id

Conversation

@edimossilva
Copy link
Copy Markdown
Member

Summary

Follow-up to #223. After migrating `users.id` to UUID, visiting `/admin` raised:

```
invalid value for Float(): "0518a959-ac58-4a71-9fe5-448510a1478f"
```

Cause: `UserDashboard` declared `id: Field::Number`, which Administrate renders by calling `Float()` on the value. UUIDs aren't coercible to floats, so the index page crashed before rendering any rows.

Fix: change to `Field::String` (matching how `ApiRequestLogDashboard` already represents its UUID id).

Test plan

  • `docker compose exec web bin/rails db:drop db:create db:migrate db:seed`
  • Sign in to `/admin` as `admin@email.com / password`
  • `/admin`, `/admin/users`, `/admin/api_request_logs`, `/admin/daily_overview`, `/admin/requests_dashboard`, `/admin/api_error_logs`, `/admin/user_analytics`, `/admin/user_lookup`, `/admin/request_logs_by_payload` all return 200 (verified locally).

🤖 Generated with Claude Code

edimossilva and others added 2 commits May 7, 2026 17:55
UserDashboard declared id: Field::Number, which calls Float() on the
value. After the users.id migration to uuid in #223, visiting /admin
raised "invalid value for Float(): \"<uuid>\"" before any rows could
render. Switching to Field::String (matching ApiRequestLogDashboard)
lets Administrate render the UUID as plain text.

Verified end-to-end: GET /admin and every dashboard introduced in #223
(/admin/users, /admin/api_request_logs, /admin/daily_overview,
/admin/requests_dashboard, /admin/api_error_logs, /admin/user_analytics,
/admin/user_lookup, /admin/request_logs_by_payload) return 200.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Override after_sign_in_path_for in ApplicationController so that a User
with admin? lands on admin_root_path. Non-admin users continue to use
Devise's default (stored_location_for or root_path via super).

Verified manually: signing in as admin@email.com returns 303 to
http://localhost:3002/admin.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@edimossilva edimossilva merged commit 1ca30ce into main May 7, 2026
3 checks passed
@edimossilva edimossilva deleted the fix-user-dashboard-uuid-id branch May 7, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant