Class: InsightsCloud::SettingsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/insights_cloud/settings_controller.rb

Instance Method Summary collapse

Instance Method Details

#set_org_parameterObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/insights_cloud/settings_controller.rb', line 12

def set_org_parameter
  parameter = params.require(:parameter)
  new_value = ActiveModel::Type::Boolean.new.cast(params.require(:value))
  org_id = params.require(:organization_id)

  organization = Organization.authorized.find(org_id)

  org_param = organization.organization_parameters.find_or_create_by(name: parameter) do |org_param|
    org_param.name = parameter
  end
  org_param.value = new_value
  org_param.save!
end

#showObject



3
4
5
# File 'app/controllers/insights_cloud/settings_controller.rb', line 3

def show
  render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
end

#updateObject



7
8
9
10
# File 'app/controllers/insights_cloud/settings_controller.rb', line 7

def update
  Setting[:allow_auto_insights_sync] = settings_params
  render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
end