/
ArtSerg
/
IntegrationProject
Обзор
Документация
Войти
/
ArtSerg
/
IntegrationProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
lab3
app/controllers/api/v2/authors_controller.rb
49 строк
1 KB
Yuriy
fix cors
12 дек 2025, 23:25
12 дек 2025, 23:25
5949767
Код
Авторство
О чём код?
module Api module V2 class AuthorsController < ApplicationController include IdempotentRequest def index authors = AuthorResource.all(params) respond_with(authors) end def show author = AuthorResource.find(params) respond_with(author) end def create with_idempotency do author = AuthorResource.build(params) if author.save render jsonapi: author, status: 201 else render jsonapi_errors: author end end end def update author = AuthorResource.find(params) if author.update_attributes render jsonapi: author else render jsonapi_errors: author end end def destroy author = AuthorResource.find(params) if author.destroy render jsonapi: { meta: {} }, status: 200 else render jsonapi_errors: author end end end end end