Class: Dunlop::WorkflowInstancesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dunlop/workflow_instances_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#store_or_reset_params_q

Instance Method Details

#categorize_asObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/dunlop/workflow_instances_controller.rb', line 11

def categorize_as
  scenario_name = params[:scenario].to_s
  target_scenario_class = "WorkflowInstance::#{scenario_name.classify}".safe_constantize
  @records = WorkflowInstance.find ids_param
  @records.each do |record|
    if can? :categorize_as, target_scenario_class
      record.categorize_as scenario_name
    end
  end
  redirect_path = polymorphic_path([main_app, :selection, target_scenario_class], ids: ids_param.join(RecordCollection.ids_separator))
  respond_to do |format|
    format.html { redirect_to redirect_path }
    format.js { render js: "window.location = '#{redirect_path}'" }
  end
end

#resetObject



5
6
7
8
9
# File 'app/controllers/dunlop/workflow_instances_controller.rb', line 5

def reset
  authorize! :reset, @record
  @record.reset!
  redirect_to @record
end