summaryrefslogtreecommitdiffhomepage
path: root/app/controllers/api/v1/games_controller.rb
blob: 75d08a93c6c9402d7c570203398108613b700878 (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
class Api::V1::GamesController < ApplicationController
  skip_before_action :verify_authenticity_token
  def create
    @game = Game.new(games_params)
    if @game.save
      pp @game
      render json: @game, status: :created
    else
      render json: @game.errors, status: :unprocessable_entity
    end
  end

  def index
    game = Game.all.order(created_at: :desc)
    #render json: game
    render html: Game.first.game_file.download.html_safe
  end

  private

  def games_params
    params.require(:game).permit(:title, game_files:)
  end
end