Commit 65e4379
committed
resolve nested model classes in HomeHelper#metadata
`metadata(cls)` did a bare `LinkedData::Models.const_get(name)`, so
requests like `GET /metadata/Reply` blew up with
`NameError: uninitialized constant LinkedData::Models::Reply` —
`Reply` lives under `LinkedData::Models::Notes`, not at the top level.
`routes_by_class` already has sub-module search for the same reason;
`metadata` was missing the mirror.
Extract a small `resolve_model_class(name)` helper that tries the
top-level lookup first and falls back to scanning
`LinkedData::Models.constants` for the name, matching the behavior of
`routes_by_class`. This restores `GET /metadata/Reply` and any other
nested model class (e.g. `Users::Role`, `Users::NotificationType`).
test_metadata_route_resolves_submodule_class now passes.1 parent 1c3d329 commit 65e4379
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
51 | 63 | | |
52 | 64 | | |
53 | 65 | | |
| |||
0 commit comments