about summary refs log tree commit diff stats
path: root/data/maps/the_parthenon/metadata.txtpb
diff options
context:
space:
mode:
Diffstat (limited to 'data/maps/the_parthenon/metadata.txtpb')
0 files changed, 0 insertions, 0 deletions
'#n28'>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_attributes(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