summaryrefslogtreecommitdiff
path: root/app/controllers/runs_controller.rb
blob: 1495d785f9d9d09951a07296295ad7569af879da (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 run."
    else
      render :new, status: :unprocessable_entity
    end
  end

protected

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