Method: Effective::Resources::Controller#submits

Defined in:
app/models/effective/resources/controller.rb

#submitsObject

Used by effective_form_submit The actions we would use to commit. For link_to { ‘Save’: { action: :save }, ‘Continue’: { action: :save }, ‘Add New’: { action: :save }, ‘Approve’: { action: :approve } } Saves a list of commit actions…



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/effective/resources/controller.rb', line 9

def submits
  {}.tap do |submits|
    if (actions.find { |a| a == :create } || actions.find { |a| a == :update })
      submits['Save'] = { action: :save, default: true }
    end

    if actions.find { |a| a == :index }
      submits['Continue'] = { action: :save, redirect: :index, default: true, unless: -> { params[:_datatable_id].present? } }
    end

    if actions.find { |a| a == :new }
      submits['Add New'] = { action: :save, redirect: :new, default: true, unless: -> { params[:_datatable_id].present? } }
    end
  end
end