summaryrefslogtreecommitdiff
path: root/app/controllers/runs_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/runs_controller.rb')
-rw-r--r--app/controllers/runs_controller.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/controllers/runs_controller.rb b/app/controllers/runs_controller.rb
new file mode 100644
index 0000000..303c0e3
--- /dev/null
+++ b/app/controllers/runs_controller.rb
@@ -0,0 +1,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