JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
can I do unscoped inside filter
还没有人认领这个 Issue。
- 主要语言
- Ruby
- 星标
- 2.3k
- 派生
- 546
- PR 合并指标
- 30 天内没有已合并 PR
描述
I override self.records methods
def self.records(options = {})
Course.index_page
end
which return courses that have index flag.
in a filter, I'd like to return all courses that I've purchased.
filter :paid, apply: ->(records, _value, _options) {
records.unscoped.where(id: some_ids)
}
an error was returned if some_ids includes course that doesn't have index flag.
Internal Server Error: undefined method id' for nil:NilClass /../../gems/jsonapi-resources-ad12cbab49cf/lib/jsonapi/resource_serializer.rb:59:in block in serialize_to_hash'
do I implement it in a wrong way, or some issues here?
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从自定义的 records 方法和 filter :paid 回调开始,然后检查第 59 行的 jsonapi/resource_serializer.rb。使用包含一个没有 index 标志的课程的 some_ids 重现失败,并确定未限定 scope 的结果是否符合 serializer 的预期;当行为得到澄清,并由适当的回归测试覆盖或记录为不受支持时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rails, ruby
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 20/100