Class: Admin::LabelsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/labels_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/labels_controller.rb', line 18

def create
  @label = Label.new(label_params)
  @label.template = true

  if @label.save
    redirect_to admin_labels_url, notice: "Label was created"
  else
    render :new
  end
end

#destroyObject


37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/admin/labels_controller.rb', line 37

def destroy
  @label.destroy
  @labels = Label.templates

  respond_to do |format|
    format.html do
      redirect_to(admin_labels_path, notice: 'Label was removed')
    end
    format.js
  end
end

#editObject


15
16
# File 'app/controllers/admin/labels_controller.rb', line 15

def edit
end

#indexObject


4
5
6
# File 'app/controllers/admin/labels_controller.rb', line 4

def index
  @labels = Label.templates.page(params[:page])
end

#newObject


11
12
13
# File 'app/controllers/admin/labels_controller.rb', line 11

def new
  @label = Label.new
end

#showObject


8
9
# File 'app/controllers/admin/labels_controller.rb', line 8

def show
end

#updateObject


29
30
31
32
33
34
35
# File 'app/controllers/admin/labels_controller.rb', line 29

def update
  if @label.update(label_params)
    redirect_to admin_labels_path, notice: 'label was successfully updated.'
  else
    render :edit
  end
end