Class: LatoSettings::SettingsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/lato_settings/settings_controller.rb', line 18

def create
  @setting = Setting.new(setting_params)
  if @setting.save
    redirect_to settings_path
  else
    render 'new'
  end
end

#destroyObject



40
41
42
43
44
# File 'app/controllers/lato_settings/settings_controller.rb', line 40

def destroy
  @setting = Setting.find(params[:id])
  @setting.destroy
  redirect_to settings_path
end

#editObject



27
28
29
# File 'app/controllers/lato_settings/settings_controller.rb', line 27

def edit
  @setting = Setting.find(params[:id])
end

#indexObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/lato_settings/settings_controller.rb', line 3

def index
  @settings = lato_index_collection(
    Setting.all,
    columns: %i[label value key updated_at actions],
    searchable_columns: %i[key label value],
    sortable_columns: %i[updated_at],
    pagination: true,
    default_sort_by: "key|asc"
  )
end

#newObject



14
15
16
# File 'app/controllers/lato_settings/settings_controller.rb', line 14

def new
  @setting = Setting.new(typology: params[:typology])
end

#updateObject



31
32
33
34
35
36
37
38
# File 'app/controllers/lato_settings/settings_controller.rb', line 31

def update
  @setting = Setting.find(params[:id])
  if @setting.update(setting_params)
    redirect_to settings_path
  else
    render 'edit'
  end
end