Class: Panda::Core::Admin::FeatureFlagsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/panda/core/admin/feature_flags_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#add_breadcrumb, #authenticate_admin_user!, #authenticate_user!, #breadcrumbs, #current_user, #set_current_request_details, #user_signed_in?

Methods included from Panda::Core::Authorizable

#authorize!, #authorized_for?, #authorized_for_admin_access?, #can?

Instance Method Details

#indexObject



9
10
11
12
# File 'app/controllers/panda/core/admin/feature_flags_controller.rb', line 9

def index
  @feature_flags = FeatureFlag.order(:key)
  @grouped_flags = @feature_flags.group_by { |flag| flag.key.split(".").first }
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/panda/core/admin/feature_flags_controller.rb', line 14

def update
  @feature_flag = FeatureFlag.find(params[:id])
  FeatureFlag.toggle!(@feature_flag.key)

  new_state = @feature_flag.reload.enabled? ? "enabled" : "disabled"
  flash[:success] = "Feature flag \"#{@feature_flag.key}\" has been #{new_state}."
  redirect_to admin_feature_flags_path
rescue ActiveRecord::RecordNotFound
  flash[:alert] = "Feature flag not found."
  redirect_to admin_feature_flags_path
end