class Admin::ConfigurationController
def edit
def edit render end
def initialize_config
def initialize_config @trusty_config = {} end
def show
def show @user = current_user render end
def update
def update if params[:trusty_config] begin TrustyCms.config.transaction do params[:trusty_config].each_pair do |key, value| @trusty_config[key] = TrustyCms::Config.find_or_initialize_by(key: key) @trusty_config[key].value = value # validation sets errors on @trusty_config['key'] that the helper methods will pick up end redirect_to action: :show end rescue ActiveRecord::RecordInvalid => e flash[:error] = 'Configuration error: please check the form' render action: :edit rescue TrustyCms::Config::ConfigError => e flash[:error] = "Configuration error: #{e}" render action: :edit end end end