Class: Scriptor::ScriptsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/scriptor/scripts_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
# File 'app/controllers/scriptor/scripts_controller.rb', line 3

def index
  @scripts = Scriptor::Script.all
end

#runObject



12
13
14
15
16
17
18
19
# File 'app/controllers/scriptor/scripts_controller.rb', line 12

def run
  script = Scriptor::Script.find(params[:filename])
  args = params[:args].to_s.strip.split
  script.run(*args)
  redirect_to script_path(script.filename), notice: "Script executed successfully."
rescue StandardError => e
  redirect_to script_path(script.filename), alert: "Error executing script: #{e.message}"
end

#showObject



7
8
9
10
# File 'app/controllers/scriptor/scripts_controller.rb', line 7

def show
  @script = Scriptor::Script.find(params[:filename])
  @executions = Execution.where(script_filename: @script.filename).order(id: :desc)
end