При POST запросе выходит ошибка 422 в API на Rails

Сегодня я написал простой бэкэнд на RAILS. Начал тестировать запросы в Postman и при post запросе выходит ошибка 422.В чем может быть проблема? Вот мой код:

//КОНТРОЛЛЕР
  # POST /categories
    def create
        category = Category.new(cat_params)
        if category.save
            category = find_category(category.id)
            render json: category, status: 201
        else
            # Что-то пошло не так
            render json: {errors: category.errors}, status: :unprocessable_entity
        end
    end
def cat_params
    params.require(:category).permit(:title)
end

//МОДЕЛЬ
class Category < ApplicationRecord
    has_many :todos, dependent: :destroy
    validates :title, presence: true, uniqueness: true
end

Буду рад любой помощи.


Ответы (0 шт):