Class: AdSpace::SlotsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ad_space/slots_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#_current_user, #add_breadcrumb, #breadcrumbs, #init_app

Instance Method Details

#createObject

POST /slots



31
32
33
34
35
36
37
38
39
# File 'app/controllers/ad_space/slots_controller.rb', line 31

def create
  @slot = Slot.new(slot_params)

  if @slot.save
    redirect_to @slot, notice: "Slot was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /slots/1



51
52
53
54
# File 'app/controllers/ad_space/slots_controller.rb', line 51

def destroy
  @slot.destroy!
  redirect_to slots_url, notice: "Slot was successfully destroyed.", status: :see_other
end

#editObject

GET /slots/1/edit



26
27
28
# File 'app/controllers/ad_space/slots_controller.rb', line 26

def edit
  add_breadcrumb(t("home"), root_path)
end

#indexObject

GET /slots



6
7
8
9
10
# File 'app/controllers/ad_space/slots_controller.rb', line 6

def index
  @slots = Slot.all

  add_breadcrumb(t("home"), root_path)
end

#newObject

GET /slots/new



19
20
21
22
23
# File 'app/controllers/ad_space/slots_controller.rb', line 19

def new
  @slot = Slot.new

  add_breadcrumb(t("home"), root_path)
end

#remove_demoObject



56
57
58
59
60
# File 'app/controllers/ad_space/slots_controller.rb', line 56

def remove_demo
  @slot.demo.purge if @slot.demo.attached?

  render json: { success: true }
end

#showObject

GET /slots/1



13
14
15
16
# File 'app/controllers/ad_space/slots_controller.rb', line 13

def show
  add_breadcrumb(t("home"), root_path)
  add_breadcrumb(t("slots"), slots_path)
end

#updateObject

PATCH/PUT /slots/1



42
43
44
45
46
47
48
# File 'app/controllers/ad_space/slots_controller.rb', line 42

def update
  if @slot.update(slot_params)
    redirect_to @slot, notice: "Slot was successfully updated.", status: :see_other
  else
    render :edit, status: :unprocessable_entity
  end
end