Class: ConfigManager::SettingsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/config_manager/settings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

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

#destroyObject

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

#indexObject

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)
  @tags = Setting.tags.join(', ')
end