diff options
Diffstat (limited to 'app/controllers/checkpoints_controller.rb')
-rw-r--r-- | app/controllers/checkpoints_controller.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/controllers/checkpoints_controller.rb b/app/controllers/checkpoints_controller.rb new file mode 100644 index 0000000..94df2c3 --- /dev/null +++ b/app/controllers/checkpoints_controller.rb @@ -0,0 +1,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) + end + + def set_run + @run = Run.find(params[:run_id]) + end +end |