-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature Flags
Feature flags allow us to enable/disable and perform phased rollouts for new features on the site.
To add a new feature flag...
-
Go to the db/seeds/feature_flags.rb file
-
Add your feature flag name to the
FEATURE_FLAGS
array at the top of the file.Example:
FEATURE_FLAGS = %i[my_feature].freeze
-
Then, in your command line, run
bin/rails db:seed
Feature flags can be used anywhere, but you'll find yourself mostly using them in controllers and views.
Controller example:
class MyController < ApplicationController
def show
if Feature.enabled?(:my_feature, current_user)
# do something
else
redirect_to home_path, notice: "Feature not enabled"
end
end
View example:
<% if Feature.enabled?(:my_feature, current_user) do %>
<p>My feature is enabled!</p>
<% end %>
Feature flags are enabled by default in development and review app environments. If you want to disable a feature flag in these environments or enable a feature flag in production, you'll have to do it through the UI in our admin section of the site.
- Visit /admin
- If you're in production, log into your admin account otherwise use our admin dummy account
- email: [email protected]
- password: password123
- Got to Tools > Feature flags
- Find and click on your feature on the list
From here, you have a couple of options...
If the feature is not currently enabled, a "Fully enable" button will be present. "Clicking it will enable the feature for everyone on the site
When a feature is already enabled, you can disable it at any point:
If you want to roll your feature out slowly to gauge feedback without affecting everyone on the site. You can enable it for a percentage of users using "Enabled for X% of actors".
Wiki Home | Odin Web App Home | Odin Site Home | Odin Org Home
Want to contribute to this wiki? Open an issue to suggest changes and improve these docs 🚀