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

Grape::Entity::Delegator::HashObject fails when extracting string keys

Đang mở
#223 4 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
ruby
Lĩnh vực
api

Hướng nghiên cứu

Start in Grape::Entity::Delegator::HashObject, where attributes are extracted from the presented hash. Reproduce the issue with string-keyed values, then verify that string keys render correctly without breaking symbol-keyed hashes.

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

Mô tả

feature question

Hi,

I was trying to present a hash of values with a grape entity. The keys in the hash were strings and I got null values all over the place as a response.

It boils down to Grape::Entity::Delegator::HashObject, when it tries to render the attribute it only tries to extract the attribute with a symbol as a key and not a string.

screen shot 2016-05-30 at 13 50 29

I think a simple
object[attribute] || object[attribute.to_s]
would fix the issue, although I'm not sure whether you need to make the destinction between symbols and strings there for other reasons. For now I simple convert all my keys to symbols before handing them to grape entity. But in any case would be more convenient the other way around.

Cheers
Tom

Ngôn ngữ chính
Ruby
Star
730
Fork
154
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

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 ruby-grape/grape-entity

Tất cả issue của ruby-grape/grape-entity

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.