dawarich/app/controllers/settings_controller.rb

38 lines
790 B
Ruby
Raw Normal View History

2024-05-18 06:13:29 -04:00
# frozen_string_literal: true
class SettingsController < ApplicationController
before_action :authenticate_user!
def index
end
def update
current_user.update(settings: settings_params)
flash.now[:notice] = 'Settings updated'
redirect_to settings_path, notice: 'Settings updated'
end
2024-05-18 06:13:29 -04:00
def theme
current_user.update(theme: params[:theme])
redirect_back(fallback_location: root_path)
end
def generate_api_key
current_user.update(api_key: SecureRandom.hex)
redirect_back(fallback_location: root_path)
end
private
def settings_params
params.require(:settings).permit(
2024-07-24 14:25:16 -04:00
:meters_between_routes, :minutes_between_routes, :fog_of_war_meters,
:time_threshold_minutes, :merge_threshold_minutes, :route_opacity
)
end
2024-05-18 06:13:29 -04:00
end