JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
RecordNotFound should receive associated resource class
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Ruby
- Star
- 2.3k
- Fork
- 546
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
The message from record not found only pass ID as attribute.
I think it would be better to pass the resource class as well so that we can have something like
detail: I18n.translate('jsonapi-resources.exceptions.record_not_found.detail',
default: "The #{resource.name} identified by #{id} could not be found.", id: id, type: resource.class))]
Or maybe the associated activerecord class
This is the current implementation
class RecordNotFound < Error
attr_accessor :id
def initialize(id)
@id = id
end
def errors
[JSONAPI::Error.new(code: JSONAPI::RECORD_NOT_FOUND,
status: :not_found,
title: I18n.translate('jsonapi-resources.exceptions.record_not_found.title',
default: 'Record not found'),
detail: I18n.translate('jsonapi-resources.exceptions.record_not_found.detail',
default: "The record identified by #{id} could not be found.", id: id))]
end
end
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách lần theo class RecordNotFound và các caller của nó, tập trung vào bản dịch detail của JSONAPI::Error và khóa I18n record_not_found được nêu trong issue. Xác định xem lỗi nên để lộ class tài nguyên JSON:API hay class ActiveRecord liên kết với nó, sau đó xác minh rằng thông báo not-found kết quả có chứa ngữ cảnh tài nguyên và ID dự kiến hay không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- rails, ruby
- Lĩnh vực
- api, backend
- Loại issue
- Tính năng
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100