Class: Apify::Scheduler::UnitsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/apify/scheduler/units_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /units



28
29
30
31
32
33
34
35
36
# File 'app/controllers/apify/scheduler/units_controller.rb', line 28

def create
  @unit = Apify::Scheduler::Unit.new(unit_params)

  if @unit.save
    redirect_to @unit, notice: 'Unit was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /units/1



56
57
58
59
# File 'app/controllers/apify/scheduler/units_controller.rb', line 56

def destroy
  @unit.destroy
  redirect_to units_url, notice: 'Unit was successfully destroyed.'
end

#editObject

GET /units/1/edit



24
25
# File 'app/controllers/apify/scheduler/units_controller.rb', line 24

def edit
end

#indexObject

GET /units



10
11
12
# File 'app/controllers/apify/scheduler/units_controller.rb', line 10

def index
  @units = Apify::Scheduler::Unit.all
end

#newObject

GET /units/new



19
20
21
# File 'app/controllers/apify/scheduler/units_controller.rb', line 19

def new
  @unit = Apify::Scheduler::Unit.new
end

#performObject

POST /units/1/perform



48
49
50
51
52
53
# File 'app/controllers/apify/scheduler/units_controller.rb', line 48

def perform
  worker = @unit.enqueue
  message   = worker ? "Successfully added #{@unit.name} unit to queue. Refresh page to see progress." : "Error occured while queuing #{@unit.name}. Try again"
  flash_key = worker ? :notice : :error
  redirect_to units_path, flash: { flash_key => message }
end

#showObject

GET /units/1



15
16
# File 'app/controllers/apify/scheduler/units_controller.rb', line 15

def show
end

#updateObject

PATCH/PUT /units/1



39
40
41
42
43
44
45
# File 'app/controllers/apify/scheduler/units_controller.rb', line 39

def update
  if @unit.update(unit_params)
    redirect_to @unit, notice: 'Unit was successfully updated.'
  else
    render :edit
  end
end