Class: WorkflowInstanceBatchesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- WorkflowInstanceBatchesController
- Defined in:
- lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #with_mixed_bas_completeness ⇒ Object
Class Method Details
.workflow_instance_batch_class ⇒ Object
51 52 53 54 55 56 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 51 def workflow_instance_batch_class return @workflow_instance_batch_class if @workflow_instance_batch_class parts = controller_path.split('/').map(&:classify) parts.pop until klass = parts.join('::').safe_constantize @workflow_instance_batch_class = klass end |
.workflow_instance_class ⇒ Object
58 59 60 61 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 58 def workflow_instance_class return @workflow_instance_class if @workflow_instance_class @workflow_instance_class = workflow_instance_batch_class.name.sub('Batch', '').constantize end |
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 22 def create @record = workflow_instance_batch_class.new(record_params) :manage, @record if @record.save redirect_to action: :index else render action: "new" end end |
#edit ⇒ Object
37 38 39 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 37 def edit :manage, @record end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 6 def index :read, workflow_instance_batch_class @q = workflow_instance_batch_class.search(params[:q]) @q.sorts = "plan_date ASC" if @q.sorts.empty? @records = @q.result.page(params[:page]).per(params[:per_page]) end |
#new ⇒ Object
13 14 15 16 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 13 def new :manage, workflow_instance_batch_class @record = workflow_instance_batch_class.new end |
#show ⇒ Object
32 33 34 35 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 32 def show :read, @record respond_with @record, record_class: workflow_instance_class, include_notes: params[:include_notes] end |
#update ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 41 def update :manage, @record if @record.update record_params redirect_to action: :index else render action: :edit end end |
#with_mixed_bas_completeness ⇒ Object
18 19 20 |
# File 'lib/generators/dunlop/install/workflow/templates/controllers/workflow_instance_batches_controller.rb', line 18 def with_mixed_bas_completeness @records = workflow_instance_batch_class.with_mixed_bas_load_states end |