Sha256: e5b2d8640f7ea12ec7a49eb0855f1b9837b9ca79aa9a181ca3bb609c2a61699d

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 KB

Contents

# == Schema Information
#
# Table name: easy_ml_settings
#
#  id                   :bigint           not null, primary key
#  storage              :string
#  timezone             :string
#  s3_access_key_id     :string
#  s3_secret_access_key :string
#  s3_bucket            :string
#  s3_region            :string
#  s3_prefix            :string
#  created_at           :datetime         not null
#  updated_at           :datetime         not null
#
module EasyML
  class SettingsController < ApplicationController
    def index
      @settings = Settings.first_or_create
      render inertia: "pages/SettingsPage", props: {
        settings: { settings: settings_to_json(@settings) },
      }
    end

    def update
      @settings = Settings.first_or_create

      @settings.update(settings_params)
      EasyML::Configuration.configure do |config|
        config.storage = @settings.storage
        config.timezone = @settings.timezone
        config.s3_bucket = @settings.s3_bucket
        config.s3_region = @settings.s3_region
        config.s3_prefix = @settings.s3_prefix
        config.wandb_api_key = @settings.wandb_api_key
      end
      flash.now[:notice] = "Settings saved."
      render inertia: "pages/SettingsPage", props: {
        settings: @settings.as_json,
      }
    end

    private

    def settings_params
      params.require(:settings).permit(
        :storage,
        :timezone,
        :s3_bucket,
        :s3_region,
        :s3_prefix,
        :wandb_api_key
      )
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc52 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc51 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc50 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc49 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc48 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc47 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc46 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc45 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc44 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc43 app/controllers/easy_ml/settings_controller.rb