Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Enable/Disable a Feature

There are two ways to control a feature.

The old way

We use the rails-settings-cached gem How to use it in code

  1. update config/admin_setting.yml then add a new key, for example feature_xfeature_x: false
  2. Then we can call the config from AdminSetting.feature_x example: if AdminSetting.feature_x You can change the value by: AdminSetting.feature_x = true Every key in admin_setting.yml will appear on the settings page. http://localhost:3000/admin/settings

The new way

we use Flipper gem to toggle a feature availability, for example, https://hhstaging.hungryhub.com/admin/flipper/features see more about it at https://www.flippercloud.io/docs


How does the client app know if the feature is available or not

Update app/controllers/api/v5/pages_controller.rb, di app_config add new key there example :

feature_x: AdminSetting.feature_x.to_s == 'true'

From the new way add :

render json: { 
  success: true, 
  data: config.merge(
    feature_x: Flipper.enabled?(:feature_x)
  ), 
  message: nil 
}

add the flipper to data migration so the UI can be updated

def up
  Flipper.disable :xxx
end