diff --git a/app/views/demo/actor.html.erb b/app/views/demo/actor.html.erb index 23720c8..bf85359 100644 --- a/app/views/demo/actor.html.erb +++ b/app/views/demo/actor.html.erb @@ -12,7 +12,7 @@
Previously, we enabled the demo for all users. While that's the simplest case and very handy when a feature is completely ready, you'll occasionally want to enable a feature for a single individual like yourself or a teammate. So let's see how that works.
-We've named this feature flag demo_actor
because it only enables the feature for a single user. In this case, we'll use current_user
, but in practice, you could use any instance of a User, Organization, Team, or any "actor" from your system as long as the instance responds to flipper_id
.
We've named this feature flag :demo_actor
because it only enables the feature for a single user. In this case, we'll use current_user
, but in practice, you could use any instance of a User, Organization, Team, or any "actor" from your system as long as the instance responds to flipper_id
.
Important: In order to enable access for individual users, accounts, or any other actor the model must respond to a flipper_id
method that returns a unique identifier.
The demo_actor
feature is enabled for everyone.
The :demo_actor
feature is enabled for everyone.
The demo_actor
feature is disabled for anyone that doesn't have special authorization.
The :demo_actor
feature is disabled for anyone that doesn't have special authorization.
The demo_actor
feature is implicitly enabled for you since it's enabled for everyone.
The :demo_actor
feature is implicitly enabled for you since it's enabled for everyone.
The demo_actor
feature is explicitly enabled for you.
The :demo_actor
feature is explicitly enabled for you.
The demo_actor
feature is implicitly disabled for you as well.
The :demo_actor
feature is implicitly disabled for you as well.
The demo_group
feature is enabled for you since you prefer coffee. Nice work! Next we'll look at how you can enable features for a percentage of users.
The :demo_group
feature is enabled for you since you prefer coffee. Nice work! Next we'll look at how you can enable features for a percentage of users.
The demo_group
feature is disabled for you since you don't prefer coffee. Let's update your beverage preference so you'll be included in the coffee drinkers group and get access.
The :demo_group
feature is disabled for you since you don't prefer coffee. Let's update your beverage preference so you'll be included in the coffee drinkers group and get access.
The demo_group
feature is enabled for everyone.
The :demo_group
feature is enabled for everyone.
The demo_group
feature is disabled for anyone that doesn't have special authorization.
The :demo_group
feature is disabled for anyone that doesn't have special authorization.
The demo_group
feature is enabled for water drinkers.
The :demo_group
feature is enabled for water drinkers.
The demo_group
feature is disabled for water drinkers.
The :demo_group
feature is disabled for water drinkers.
The demo_group
feature is enabled for tea drinkers.
The :demo_group
feature is enabled for tea drinkers.
The demo_group
feature is disabled for tea drinkers.
The :demo_group
feature is disabled for tea drinkers.
The demo_group
feature is enabled for coffee drinkers.
The :demo_group
feature is enabled for coffee drinkers.
The demo_group
feature is disabled for coffee drinkers.
The :demo_group
feature is disabled for coffee drinkers.
Let's explore toggling by using percentages where we can enable a feature for a percentage of actors or for a percentage of time. As we're increasingly confident there aren't any surprise bugs or performance issues, we can gradually increase the percentage.
-We've named this feature flag slow_roll
since we'll slowly roll it out to more users. We'll increase our percentage gradually in increments of 25% and see how it four different user accounts, including yours, are affected.
We've named this feature flag :slow_roll
since we'll slowly roll it out to more users. We'll increase our percentage gradually in increments of 25% and see how it four different user accounts, including yours, are affected.
This is great for refactoring a significant portion of code so you can keep the legacy portion in place in parallel with the new code that's set to replace it, and you can slowly send more traffic down the new code path until you're confident it's generating the same results as the original.
diff --git a/app/views/example/_backup_providers.html.erb b/app/views/example/_backup_providers.html.erb index 24c8a79..4d325ba 100644 --- a/app/views/example/_backup_providers.html.erb +++ b/app/views/example/_backup_providers.html.erb @@ -233,7 +233,7 @@Important: Behind the scenes, we've already registered and defined the coffee drinker group in config/initializers/flipper.rb
:
Important: Behind the scenes, we've already registered and defined the :paid
group in config/initializers/flipper.rb
:
Flipper.register(:paid) do |actor, context|
actor.respond_to?(:paid?) && actor.paid?
diff --git a/app/views/example/_circuit_breakers.html.erb b/app/views/example/_circuit_breakers.html.erb
index 432894d..9d456c8 100644
--- a/app/views/example/_circuit_breakers.html.erb
+++ b/app/views/example/_circuit_breakers.html.erb
@@ -9,14 +9,6 @@
<%= flag_status(@example.flag) %>
-
- <% [
- ['Fully enabled for everyone?', Flipper.enabled?(@example.flag), "Flipper.enabled?(:#{@example.flag})"],
- ['Enabled for the current user?', Flipper.enabled?(@example.flag, current_user), "Flipper.enabled?(:#{@example.flag}, current_user)"],
- ].each do |scenario| %>
- <%= status_item(*scenario) %>
- <% end %>
-
<% if Flipper.enabled?(@example.flag, current_user) %>
@@ -33,6 +25,19 @@
<% end %>
+
+
+ Inspect Flag State & Code Samples
+
+ <% [
+ ['Fully enabled for everyone?', Flipper.enabled?(@example.flag), "Flipper.enabled?(:#{@example.flag})"],
+ ['Enabled for the current user?', Flipper.enabled?(@example.flag, current_user), "Flipper.enabled?(:#{@example.flag}, current_user)"],
+ ].each do |scenario| %>
+ <%= status_item(*scenario) %>
+ <% end %>
+
+
+
<%= controls "Update Search" do %>
<% if Flipper.enabled?(@example.flag) %>
diff --git a/app/views/example/_managing_external_tools.html.erb b/app/views/example/_managing_external_tools.html.erb
index d98ef72..7643458 100644
--- a/app/views/example/_managing_external_tools.html.erb
+++ b/app/views/example/_managing_external_tools.html.erb
@@ -18,14 +18,6 @@
<%= flag_status(@example.flag) %>
-
- <% [
- ['Fully enabled for everyone?', Flipper.enabled?(@example.flag), "Flipper.enabled?(:#{@example.flag})"],
- ['Enabled for the current user?', Flipper.enabled?(@example.flag, current_user), "Flipper.enabled?(:#{@example.flag}, current_user)"],
- ].each do |scenario| %>
- <%= status_item(*scenario) %>
- <% end %>
-
@@ -38,6 +30,19 @@
<% end %>
+
+
+ Inspect Flag State & Code Samples
+
+ <% [
+ ['Fully enabled for everyone?', Flipper.enabled?(@example.flag), "Flipper.enabled?(:#{@example.flag})"],
+ ['Enabled for the current user?', Flipper.enabled?(@example.flag, current_user), "Flipper.enabled?(:#{@example.flag}, current_user)"],
+ ].each do |scenario| %>
+ <%= status_item(*scenario) %>
+ <% end %>
+
+
+
<%= controls "Update Search" do %>
<% if Flipper.enabled?(@example.flag, current_user) %>