summaryrefslogtreecommitdiff
path: root/app/controllers/runs_controller.rb
blob: 303c0e3cf0878886fcf797cd0383817fcaef1933 (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
28
29
class RunsController < ApplicationController
  def index
    @runs = Run.all
  end

  def show
    @run = Run.find(params[:id])
  end

  def new
    @run = Run.new
  end

  def create
    @run = Run.new(run_params)
    @run.user = current_user
    if @run.save
      redirect_to run_path(@run), notice: "Created runs."
    else
      render :new, status: :unprocessable_entity
    end
  end

protected

  def run_params
    params.require(:run).permit(:title, :description, :game_id)
  end
end