JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Included resource choosing wrong Arel table
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ả
I'm running into an issue where including one resource (user) ends up using another Arel table (account), and thus the include blows up with Internal Server Error: key not found: 11. 11 is the Account ID of the user, but the user ID is 68, which is specified on the parent resource as user_id.
I've stepped through the code a bit to determine that pluck_attrs in JSONAPI::Resource#preload_include_fragments has the wrong Arel::Table but I'm not sure what the cause of that is.
My models and resources are configured in a very straightforward manner:
JobApplication < ApplicationRecord
belongs_to :user, inverse_of: :job_applications, touch: true, counter_cache: true
end
User < ApplicationRecord
has_many :job_applications, inverse_of: :user, dependent: :destroy
end
Any idea why this would be happening?
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 trong JSONAPI::Resource#preload_include_fragments và kiểm tra cách pluck_attrs chọn Arel::Table của nó trong include JobApplication/User được mô tả. Tái hiện vấn đề với cấu hình association trong báo cáo, sau đó xác minh rằng việc include user sử dụng user_id 68 thay vì Account ID 11 và không còn gây ra lỗi không tìm thấy key.
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
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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