Add model-page protocol (v1)#12
Merged
Merged
Conversation
Reusable admin-only per-record inspector drawn into every consuming app via
Studio.routes: /models/:model/:id renders a record as pretty JSON plus a
copy/paste rails-console command; /models/:model/random jumps to a random
record. Studio::ModelPage ships an EMPTY registry — hosts opt in per model
with register("release", Release, lookup: :slug) in an initializer. Bumps
0.11.0 -> 0.12.0. Engine suite (bin/release-check) green: 10 unit + 3 route.
Task: https://mcritchie.studio/tasks/model-page-engine-protocol
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task: https://mcritchie.studio/tasks/model-page-engine-protocol
Adds a reusable, admin-only model-page protocol to the engine, drawn into every consuming app via
Studio.routes:/models/:model/:id— renders one record as pretty JSON plus a copy/paste rails-console command to reload it/models/:model/random— bounces to a random record of that model (fresh sample)What's here
Studio::ModelPage(app/models/studio/model_page.rb) — the protocol object. Ships an empty registry; a host opts in per model in an initializer:Studio::ModelPage.register("release", Release, lookup: :slug). Mirrors the admin-models host-registry pattern — the engine never constantizes host models by name; an unknown key raisesUnknownModel(rendered 404).Studio::ModelsController+app/views/studio/models/show.html.erb(engine theme tokens; reuses thecomponents/copy_buttonpartial). Admin-gated viarequire_admin.Studio.routes—randomdrawn before the:idcatch-all so it isn't swallowed as an identifier. Host-level helpers (studio_model_path,studio_model_random_path).0.11.0→0.12.0+ CHANGELOG entry.Tests
[unit]test/lib/studio/model_page_test.rb— 10 tests (registry, console command, random, JSON), pure-Ruby with a stub host model.[integration]test/integration/model_page_routes_test.rb— routes drawn under the dummy app; random-before-:idordering asserted against the route table.bin/release-checkgreen (wired both new files into its suite list).Adoption (follow-ups, gated on publishing 0.12)
releaseand adds a "Model" link on/deployments/all(the app-local proof of this is already operator-approved).🤖 Generated with Claude Code