Skip to content

STI display, boot-time flippables check, and release 0.4.0 - #3

Merged
sammyapoex merged 4 commits into
mainfrom
flippables-sti-and-boot-check
Sep 25, 2026
Merged

sammyapoex merged 4 commits into
mainfrom
flippables-sti-and-boot-check

Conversation

@sammyapoex

Copy link
Copy Markdown
Collaborator

Follow-up to #2, which was merged at 5b5d68f — three commits on that branch landed after it and are cherry-picked here, plus the release bump.

Changes

  • Display STI subclasses through their base class's registration. With flipside_entity in User, an Admin < User record was looked up as "Admin": its entity showed as User #id and display_entity(admin) raised KeyError. The registration is now looked up through the class's ancestors, so a subclass uses the closest registered class and its own registration still wins. (Handle deleted entities #2's fix covered only the subclass-registered case.)
  • Verify Flipside.flippables at boot when the app eager loads. Since Handle deleted entities #2 checks the list lazily, an unlisted class using the macros, or a listed class registering nothing, passed boot and CI and failed on the first UI visit. The Railtie now runs the same check in after_initialize when eager_load is on. Rails eager loads before after_initialize in railties 6.1, 7.0 and 8.1 (checked in source). Smoke-tested by booting a minimal Rails 8.1 app against this code: listed → boots; unlisted → Flipside::Error at boot; listed-but-missing → NameError at boot; no eager load → boots. That run also confirmed the deprecator is registered in Rails.application.deprecators.
  • README: note that soft deletes running destroy callbacks (e.g. paranoia) also remove a record's entities.
  • Bump version to 0.4.0 and date the changelog.

Releasing

bundle exec rake release does not work as-is: rake (and standard) are not in the bundle. Either add them as dev dependencies or release with gem build flipside.gemspec && gem push flipside-0.4.0.gem.

Note for apps upgrading

Apps that raise on deprecations (e.g. config.active_support.deprecation = :raise in test) will fail to boot while they still call register_entity/register_role, since the deprecator now follows the app's settings. Migrate to the macros in the same change as the bump.

Testing

bundle exec rspec — 70 examples, 0 failures.

🤖 Generated with Claude Code

Sammy Henningsson and others added 4 commits September 25, 2026 15:34
With flipside_entity in User, an Admin < User record was looked up as
"Admin", so its entity showed as "User #id" and display_entity(admin)
raised KeyError. Look the registration up through the class's ancestors,
so a subclass uses the closest registered class and its own registration
still wins when it has one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Checking the list only when the UI reads the registry meant an unlisted
class using the macros, or a listed class registering nothing, passed
boot and CI and failed on the first visit to the UI. The Railtie now
runs the same check in after_initialize when the app eager loads. Rails
eager loads before running after_initialize (6.1 through 8.1), so every
class using the macros has registered by then. Without eager loading the
check is left to the UI, since it would only see whatever is loaded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
flipside_entity's cleanup is a dependent: :delete_all association, which
runs on any destroy that runs callbacks, soft deletes included. Say so,
since a restored record comes back without its features.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sammyapoex
sammyapoex merged commit 23241c9 into main Sep 25, 2026
1 check passed
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