1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/controllers/api/event_themes_controller.rb

54 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
# API Controller for resources of type EventTheme
# EventTheme are used to classify Events
2016-06-29 10:38:04 +02:00
class API::EventThemesController < API::ApiController
before_action :authenticate_user!, except: [:index]
before_action :set_event_theme, only: %i[show update destroy]
2016-06-29 10:38:04 +02:00
def index
@event_themes = EventTheme.all
end
def show; end
2016-06-29 10:38:04 +02:00
def create
authorize EventTheme
@event_theme = EventTheme.new(event_theme_params)
if @event_theme.save
render :show, status: :created, location: @event_theme
else
render json: @event_theme.errors, status: :unprocessable_entity
end
end
def update
authorize EventTheme
if @event_theme.update(event_theme_params)
render :show, status: :ok, location: @event_theme
else
render json: @event_theme.errors, status: :unprocessable_entity
end
end
def destroy
authorize EventTheme
if @event_theme.safe_destroy
head :no_content
else
render json: @event_theme.errors, status: :unprocessable_entity
end
2016-06-29 10:38:04 +02:00
end
private
2016-06-29 10:38:04 +02:00
def set_event_theme
@event_theme = EventTheme.find(params[:id])
end
def event_theme_params
params.require(:event_theme).permit(:name)
end
end