Class: RailsWorkflow::OperationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_workflow/operations_controller.rb

Instance Method Summary collapse

Instance Method Details

#completeObject



50
51
52
53
54
55
56
57
58
# File 'app/controllers/rails_workflow/operations_controller.rb', line 50

def complete
  operation = current_operation
  if operation.present?
    operation.complete
    clear_current_operation

    redirect_to main_app.root_path
  end
end

#createObject



18
19
20
21
# File 'app/controllers/rails_workflow/operations_controller.rb', line 18

def create
  @operation = Operation.create(permitted_params)
  redirect_to process_operation_url
end

#destroyObject



60
61
62
63
# File 'app/controllers/rails_workflow/operations_controller.rb', line 60

def destroy
  @operation.destroy
  redirect_to process_operation_url
end

#indexObject



23
24
25
26
27
28
29
# File 'app/controllers/rails_workflow/operations_controller.rb', line 23

def index
  @operations = OperationDecorator.decorate_collection(
      parent.try(:operations) || Operation.waiting.order(created_at: :desc)
  )

  respond_with @operations
end

#pickupObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/rails_workflow/operations_controller.rb', line 36

def pickup
  if @operation.assign(current_user)

    set_current_operation
    redirect_to main_app.send(
                    @operation.data[:url_path],
                    *@operation.data[:url_params]
                )
  else
    redirect_to operations_path
  end

end

#updateObject



31
32
33
34
# File 'app/controllers/rails_workflow/operations_controller.rb', line 31

def update
  @operation.update(permitted_params)
  redirect_to process_operation_url
end