# Key-value store for runtime application settings that are configured through # the web setup wizard (or updated by an administrator) rather than hard-coded # in application.rb. # # Known keys: # skip_email_confirmation – "true"/"false", mirrors the homonymous option # that was previously in application.rb. class Setting < ApplicationRecord validates :key, presence: true, uniqueness: true # Return the string value stored for +key+, or +default+ when absent. def self.get(key, default: nil) find_by(key: key)&.value || default end # Persist +value+ for +key+, creating the record if it does not yet exist. def self.set(key, value) find_or_initialize_by(key: key).update!(value: value.to_s) end end