Class: ConfigManager::TogglesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ConfigManager::TogglesController
- Defined in:
- app/controllers/config_manager/toggles_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /toggles.
-
#destroy ⇒ Object
DELETE /toggles/:id.
-
#dump ⇒ Object
POST /toggles/dump.
-
#index ⇒ Object
GET /toggles.
-
#load ⇒ Object
POST /toggles/load.
Instance Method Details
#create ⇒ Object
POST /toggles
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/config_manager/toggles_controller.rb', line 10 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.}" 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 |
#destroy ⇒ Object
DELETE /toggles/:id
26 27 28 29 30 31 |
# File 'app/controllers/config_manager/toggles_controller.rb', line 26 def destroy Toggle.delete(params[:id]) flash[:notice] = "#{params[:id]} has been deleted!" redirect_to toggles_url end |
#dump ⇒ Object
POST /toggles/dump
49 50 51 |
# File 'app/controllers/config_manager/toggles_controller.rb', line 49 def dump send_data Toggle.to_yaml, :filename => 'toggles.yml' end |
#index ⇒ Object
GET /toggles
4 5 6 7 |
# File 'app/controllers/config_manager/toggles_controller.rb', line 4 def index @toggles = Toggle.toggles @toggle = Toggles::Definition.new(params[:toggle_name]) end |
#load ⇒ Object
POST /toggles/load
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/config_manager/toggles_controller.rb', line 34 def load if params[:file] loads, failures = Toggle.from_yaml(params[:file].tempfile) 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 else flash[:error] = "You must choose a file" end rescue flash[:error] = "Couldn't load toggles. Did you choose a valid file?" ensure redirect_to toggles_url end |