Class: Super::SubstructureController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/super/substructure_controller.rb

Overview

Various methods that determine the behavior of your controllers. These methods can and should be overridden.

Direct Known Subclasses

ApplicationController

Class Method Summary collapse

Class Method Details

.batch(action_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/super/substructure_controller.rb', line 7

def self.batch(action_name)
  mod = Module.new do
    define_method(action_name) do
      if !params[:batch]
        flash.alert = I18n.t("super.batch.none_error")
        return render :nothing, status: :bad_request
      end

      super()
    end
  end

  const_set("Batch__#{action_name}__#{SecureRandom.hex(4)}", mod)
  prepend(mod)

  action_name
end