Class: ConfigManager::SettingsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ConfigManager::SettingsController
- Defined in:
- app/controllers/config_manager/settings_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /settings.
-
#destroy ⇒ Object
DELETE /settings/:id.
-
#index ⇒ Object
GET /settings.
Instance Method Details
#create ⇒ Object
POST /settings
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/config_manager/settings_controller.rb', line 13 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 |
#destroy ⇒ Object
DELETE /settings/:id
24 25 26 27 28 29 |
# File 'app/controllers/config_manager/settings_controller.rb', line 24 def destroy Setting.delete(params[:id]) flash[:notice] = "#{params[:id]} has been deleted!" redirect_to settings_url end |
#index ⇒ Object
GET /settings
4 5 6 7 8 9 10 |
# File 'app/controllers/config_manager/settings_controller.rb', line 4 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) = Setting..join(', ') end |