summaryrefslogtreecommitdiff
path: root/app/controllers/checkpoints_controller.rb
blob: ef53a6b2a5b152a58f18dfa738e4d7ca425f98a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class CheckpointsController < ApplicationController
  before_action :set_run

  def new
    @checkpoint = @run.checkpoints.build
  end

  def create
    @checkpoint = @run.checkpoints.build(checkpoint_params)
    @checkpoint.user = current_user
    if @checkpoint.save
      redirect_to run_path(@run), notice: "Saved checkpoint."
    else
      render :new, status: :unprocessable_entity
    end
  end

protected

  def checkpoint_params
    params.require(:checkpoint).permit(:title, :description, :save_file, :kind)
  end

  def set_run
    @run = Run.find(params[:run_id])
  end
end