blob: 2da1e95527340a7d0b6cb499de7f717985d4e96d (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
class Admin::GamesController < Admin::AdminController
before_action :set_section
def index
@games = Game.order(created_at: :desc)
end
def drafts
@games = Game.where(created_at: :desc)
end
def new
@game = Game.new
end
def create
@game = Game.new(game_params)
if @game.save
flash.notice = "Game created successfully!"
render :edit
else
flash.alert = "Error creating game."
render :new
end
end
def edit
@game = Game.find(params[:id])
end
def update
@game = Game.find(params[:id])
if @game.update(game_params)
flash.notice = "Game updated successfully!"
else
flash.alert = "Error updating game."
end
render :edit
end
private
def game_params
params.require(:game).permit(:title, :description, :status, :progress, :score, :started_on, :finished_on)
end
def set_section
@section = "games"
end
end
|