Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support for HashWithIndifferentAccess / Symbolized Keys

未关闭
#142 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
rails, ruby
领域
database

调研方向

首先复现使用符号键的 map_attr 默认值示例,以及 ERB 的 my_data.except(:name) 示例。跟踪 issue 中提到的 map_attr 和面向视图的入口点,然后确定有无 ActiveSupport 时所支持的行为。完成的标准是:所要求的符号键和字符串键形式能够一致地工作,或者已记录受支持的限制和选项。

由索引模型根据 Issue 内容生成。

描述

feature-request

One of the predominant use cases of this SDK is IMHO writing Rails applications. Therefore it would make sense that this SDK supports Rails conventions as much as much as possible. Unfortunately it doesn't do that currently in term of keys as symbols vs strings.

The desirable version
map_attr :my_data, default_value: { items: [] }

throws an error while, as the syntax required is
map_attr :my_data, default_value: { 'items' => [] }.

Same for ERB:
<% my_data.except(:name).keys.each do |key| %>

does not work but needs to be
<% my_data.except("name").keys.each do |key| %>

This is very un-rails-y, both in models as in views, as using HashWithIndifferentAccess gives you at least both options. If you don't want to support this out of the box due to the dependency to ActiveSupport, I would at least making an option when ActiveSupport is available (or automatically use it).

主要语言
Ruby
星标
318
派生
44
平均合并
2 天 21 小时
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws/aws-record-ruby 的其他 Issue

查看 aws/aws-record-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。