Moving to github

This commit is contained in:
2026-03-28 19:24:29 -04:00
commit 036fa7ab33
302 changed files with 17838 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
module Api
module V1
class CollectionsController < BaseController
before_action :set_collection, only: [ :show, :update, :destroy ]
def index
@collections = current_user.collections.includes(:games).order(:name)
render json: @collections, include: :games
end
def show
render json: @collection, include: :games
end
def create
@collection = current_user.collections.build(collection_params)
if @collection.save
render json: @collection, status: :created
else
render json: { errors: @collection.errors.full_messages }, status: :unprocessable_entity
end
end
def update
if @collection.update(collection_params)
render json: @collection
else
render json: { errors: @collection.errors.full_messages }, status: :unprocessable_entity
end
end
def destroy
@collection.destroy
head :no_content
end
private
def set_collection
@collection = current_user.collections.find(params[:id])
end
def collection_params
params.require(:collection).permit(:name, :description, :parent_collection_id)
end
end
end
end