-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature Flags
Feature flags allow us to enable/disable features on the site.
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
endView example:
<% if Feature.enabled?(:my_feature, current_user) do %>
<p>My feature is enabled!</p>
<% end %>Feature flags are disabled by default. You need to manually enable them though the admin section of the site.
On your local environment, do the following:
- Log in using our dummy admin account
- email: [email protected]
- password: password
- Visit http://localhost:3000/admin
- Hover over the user icon in the top right hand corner of the navbar and click "FEATURE FLAGS" on the dropdown that appears
- Click the "Add feature" button
- In the input, enter the same name as you used for the feature in the code and click "Add feature".
- Given
Feature.enabled?(:my_feature) - Enter "my_feature"
- Given
From here, you have a couple of options...
Clicking "Fully enable" will enable the feature for everyone on the site
After it is fully enabled, you can toggle it off again 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 🚀