Class: EasyAdmin::SettingsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/easy_admin/settings_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#policy_for

Instance Method Details

#indexObject



5
6
7
# File 'app/controllers/easy_admin/settings_controller.rb', line 5

def index
  @feature_toggles = get_feature_toggles
end

#updateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/easy_admin/settings_controller.rb', line 9

def update
  params[:features]&.each do |feature_name, enabled|
    if enabled == "1"
      Flipper.enable(feature_name)
    else
      Flipper.disable(feature_name)
    end
  end

  # Refresh the feature toggles for the turbo frame response
  @feature_toggles = get_feature_toggles
  
  respond_to do |format|
    format.html { redirect_to settings_path, notice: "Feature toggles updated successfully" }
    format.turbo_stream { 
      render turbo_stream: turbo_stream.replace(
        "settings-sidebar", 
        EasyAdmin::SettingsSidebarComponent.new(feature_toggles: @feature_toggles, expanded: true).call
      )
    }
  end
end