From 8f4cefbbab452698b981b448babd3f408c649421 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 16 Jul 2026 17:40:06 -0500 Subject: [PATCH] Add Flipper Discards Actors When Feature Fully Enabled as a Rails TIL --- README.md | 3 +- ...cards-actors-when-feature-fully-enabled.md | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 rails/flipper-discards-actors-when-feature-fully-enabled.md diff --git a/README.md b/README.md index 64e1e40..1109a8d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1822 TILs and counting..._ +_1823 TILs and counting..._ See some of the other learning resources I work on: @@ -1180,6 +1180,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Filter ActiveStorage Blobs To Only Images](rails/filter-active-storage-blobs-to-only-images.md) - [Find Or Create A Record With FactoryBot](rails/find-or-create-a-record-with-factory-bot.md) - [Find Records With Multiple Associated Records](rails/find-records-with-multiple-associated-records.md) +- [Flipper Discards Actors When Feature Fully Enabled](rails/flipper-discards-actors-when-feature-fully-enabled.md) - [Force All Users To Sign Out](rails/force-all-users-to-sign-out.md) - [Format DateTime With Builtin Formats](rails/format-datetime-with-builtin-formats.md) - [Format Specific html.erb Template Files](rails/format-specific-html-erb-template-files.md) diff --git a/rails/flipper-discards-actors-when-feature-fully-enabled.md b/rails/flipper-discards-actors-when-feature-fully-enabled.md new file mode 100644 index 0000000..88f94c4 --- /dev/null +++ b/rails/flipper-discards-actors-when-feature-fully-enabled.md @@ -0,0 +1,36 @@ +# Flipper Discards Actors When Feature Fully Enabled + +Let's say I have a Flipper feature flag that I have enabled for a handful of +users. When I eventully go to globally enable that feature flag with the big +green 'Enable' button, the gate short-circuit evalutes to true everywhere. This +is what grants access to anyone when it is enabled. + +There is another thing that happens under the hood when the switch is flipped. +All those individual actor records I created for that feature flag get wiped +out. + +In the ideal case, that's not an issue because the flag is fully on going +forward. But what about the scenario where I need to rollback the feature +release. + +What if I'm thinking, "whoops, my team isn't ready to handle the influx of users +for this feature, I want to go back to having it partially enabled for that +small list of users for now." + +I'll be out of luck because that list of _actors_ was cleared. So if I'm +anticipating that I might want to be able to rollback in that way, I should +capture a snapshot of the set of actors I had enabled for that feature. + +```ruby +actors = Flipper[:some_feature].actors_value.to_a +puts JSON.pretty_generate(actors) +``` + +I could then iterate through that list making calls to individually enable it +for each actor: + +```ruby +Flipper.enable_actor(:some_feature, Flipper::Actor.new(flipper_id)) +``` + +I give a full example of what that script could look like in [Rollback a Flipper Feature Flag Release](https://www.visualmode.dev/rollback-a-flipper-feature-flag-release).