Sha256: c353276d32b15f880932fa0521f01cdefa7ae2ad46a6ff6321ec27fc99f9c184
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
module ConfigManager class SettingsController < ConfigManager::ApplicationController # GET /settings def index @settings = Setting.all.sort {|a,b| a.id <=> b.id} @setting = params[:setting_id] ? Setting.find(params[:setting_id], true) : Setting.new(nil, nil, nil) @tags = Setting.tags.join(', ') end # POST /settings def create @setting = Setting.create(params[:setting]) if @setting.valid? flash[:notice] = "Setting successfully created/updated" else flash[:error] = "Failed to create/update setting: #{@setting.message}" end redirect_to settings_url end # DELETE /settings/:id def destroy Setting.delete(params[:id]) flash[:notice] = "#{params[:id]} has been deleted!" redirect_to settings_url end # GET /settings/dump def dump send_data Setting.to_yaml, :filename => 'setting.yml' end # POST /settings/load def load if params[:file] loads, failures = Setting.from_yaml(params[:file].tempfile) flash[:notice] = "#{loads} settings have been loaded from the yaml file." if loads > 0 flash[:error] = "#{failures} settings failed to be loaded from the yaml file." if failures > 0 else flash[:error] = "You must choose a file." end rescue flash[:error] = "Couldn't load settings. Did you choose a valid file?" ensure redirect_to settings_url end end end
Version data entries
5 entries across 5 versions & 1 rubygems