Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Polymorphic Relationships Not Found On Aliased Resource

Đang mở
#1,453 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rails, ruby
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Không có tệp mã nguồn hoặc bài kiểm thử nào được nêu. Hãy bắt đầu bằng cách tái hiện ví dụ aliased PetOwnerResource với GET /pet_owners/123?include=pets, sau đó so sánh với request đang hoạt động của PersonResource và lần theo quá trình tìm kiếm quan hệ đa hình quanh model_name. Hoàn thành khi resource aliased tìm thấy và include các quan hệ Cat và Dog như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This issue is a (choose one):

  • Problem/bug report.
  • Feature request.
  • Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.

Checklist before submitting:

  • I've searched for an existing issue.
  • I've asked my question on Gitter and have not received a satisfactory answer.
  • I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
  • [] The feature I'm asking for is compliant with the JSON:API spec.

Description

We are using the v0-11-dev at risk.

If we define all that is necessary for a polymorphic relationship, we can include the related resources via something like GET /people/123?include=pets. Example code that works:

class PersonResource < JSONAPI::Resource
  relationship :pets, polymorphic: true, to: :many, polymorphic_types: %w[Cat Dog]
end

However if we "alias" the primary resource, the analogous request (GET /pet_owners/123?include=pets) does not find the related resources when we include the relationship:

  class PetOwnerResource < JSONAPI::Resource
    model_name 'Person'

    relationship :pets, polymorphic: true, to: :many, polymorphic_types: %w[Cat Dog]
end

It seems the related resource lookup is not taking into account that the primary/source resource might be aliased and using model_name.

Expected: the related resources are found.

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

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JSONAPI-Resources/jsonapi-resources

Tất cả issue của JSONAPI-Resources/jsonapi-resources

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.