Class: Plum::Cp::GlobalsController

Inherits:
BaseController show all
Defined in:
app/controllers/plum/cp/globals_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/plum/cp/globals_controller.rb', line 20

def create
  @global = current_site.globals.build(global_params)

  if assign_data(@global) && @global.save
    redirect_to cp_global_path(@global), notice: "Global created"
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



43
44
45
46
# File 'app/controllers/plum/cp/globals_controller.rb', line 43

def destroy
  @global.destroy
  redirect_to cp_globals_path, notice: "Global deleted"
end

#editObject



30
31
# File 'app/controllers/plum/cp/globals_controller.rb', line 30

def edit
end

#indexObject



9
10
11
# File 'app/controllers/plum/cp/globals_controller.rb', line 9

def index
  @globals = current_site.globals.order(:name)
end

#newObject



16
17
18
# File 'app/controllers/plum/cp/globals_controller.rb', line 16

def new
  @global = current_site.globals.build(data: {})
end

#showObject



13
14
# File 'app/controllers/plum/cp/globals_controller.rb', line 13

def show
end

#updateObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/plum/cp/globals_controller.rb', line 33

def update
  @global.assign_attributes(global_params)

  if assign_data(@global) && @global.save
    redirect_to cp_global_path(@global), notice: "Global updated"
  else
    render :edit, status: :unprocessable_entity
  end
end