class HryController < ApplicationController
  before_action :set_hra, only: [:show, :edit, :update, :destroy]

  # GET /hry
  # GET /hry.json
  def index
    @hry = Hra.all
  end

  # GET /hry/1
  # GET /hry/1.json
  def show
  end

  # GET /hry/new
  def new
    @hra = Hra.new
  end

  # GET /hry/1/edit
  def edit
  end

  # POST /hry
  # POST /hry.json
  def create
    @hra = Hra.new(hra_params)

    respond_to do |format|
      if @hra.save
        format.html { redirect_to @hra, notice: 'Hra was successfully created.' }
        format.json { render :show, status: :created, location: @hra }
      else
        format.html { render :new }
        format.json { render json: @hra.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /hry/1
  # PATCH/PUT /hry/1.json
  def update
    respond_to do |format|
      if @hra.update(hra_params)
        format.html { redirect_to @hra, notice: 'Hra was successfully updated.' }
        format.json { render :show, status: :ok, location: @hra }
      else
        format.html { render :edit }
        format.json { render json: @hra.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /hry/1
  # DELETE /hry/1.json
  def destroy
    @hra.destroy
    respond_to do |format|
      format.html { redirect_to hry_url, notice: 'Hra was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_hra
      @hra = Hra.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def hra_params
      params.require(:hra).permit(:nazev, :kod)
    end
end
