Sha256: cc9f6202f5d663fae98ae943b17021b588cf69a846b7a5f8bbb40b993f3617e2
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
module ConfigManager class TogglesController < ApplicationController # GET /toggles def index @toggles = Toggle.toggles @toggle = Toggles::Definition.new(params[:toggle_name]) end # POST /toggles def create @toggle = Toggle.create(params[:toggle]) if @toggle.valid? flash[:notice] = "Toggle successfully created/updated" else flash[:error] = "Failed to create/update toggle: #{@toggle.message}" end redirect_to toggles_url rescue Rails.logger.error "Error raised trying to create/update toggle. #{$!}. #{$!.backtrace.take(3)}" flash[:error] = "Error raised trying to create/update toggle: #{$!}" redirect_to toggles_url end # DELETE /toggles/:id def destroy Toggle.delete(params[:id]) flash[:notice] = "#{params[:id]} has been deleted!" redirect_to toggles_url end # POST /toggles/load_default def load_default loads, failures = Toggle.from_yaml(Rails.root.join('config/config_manager_toggles.yml')) flash[:notice] = "#{loads} toggles have been loaded from the yaml file." if loads > 0 flash[:error] = "#{failures} toggles failed to be loaded from the yaml file" if failures > 0 redirect_to toggles_url rescue Errno::ENOENT flash[:error] = "Couldn't load toggles. config_manager_toggles.yml not found in config directory." redirect_to toggles_url end # POST /toggles/dump def dump path = Rails.root.join('config/config_manager_toggles.yml') Toggle.to_yaml(path) flash[:notice] = "Toggles dumped to #{path}" rescue flash[:error] = "Failed to dump toggles to #{path}" ensure redirect_to toggles_url end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
config_manager-0.0.1 | app/controllers/config_manager/toggles_controller.rb |