aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/results_controller.rb
blob: 60ade5adc0c540483fe0a4d40c790adbc4f6526e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class ResultsController < ApplicationController
  before_action :set_result, only: [:show]

  def run
    compiler = Compiler.find(params[:compiler_id])
    snippet = Snippet.find(params[:snippet_id])
    @result = compiler.run(snippet)

    show
  end

  def show
    render text: render_to_string(partial: "results/result", locals: { result: @result, compiler: @result.compiler }), content_type: "text/plain"
  end

  private
  def set_result
    @result = Result.find(params[:id])
  end
end