Error "undefined method 'where' for" error on ActiveModel based resource
还没有人认领这个 Issue。
评估
调研方向
从 jsonapi/active_relation_resource.rb 开始,重点查看 apply_filter 和 apply_filters,使用报告的 JSONAPI Resources 0.9.12 到 0.10.7 的变更以及仅使用 ActiveModel 的 AuthorizeV2 示例来重现故障。将其行为与基于 ActiveRecord 的 resource 进行比较,并定义一个回归测试,使其在过滤 ActiveModel resource 不再引发报告的错误后通过。
由索引模型根据 Issue 内容生成。
描述
We just tried moving from v0.9.12 to v0.10.7 (and even tried with lower 10.x versions) and now our ActiveModel based models no longer work via resources. We now get a Internal Server Error: undefined method 'where' for error. Not sure what to do. Any help is greatly appreciated.
2025-02-24 20:22:55.712035 E [16:puma srv tp 004 acts_as_resource_controller.rb:289] {uuid: 0f40c8d0c138f0444cf4be9f7a8ec7ae} Rails -- Internal Server Error: undefined method `where' for AuthorizeV2:Class /app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:877:in `apply_filter'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:846:in `block in apply_filters'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:845:in `each'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:845:in `apply_filters'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:777:in `filter_records'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:707:in `apply_request_settings_to_records'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/active_relation_resource.rb:107:in `find_fragments'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:412:in `find_resource_id_tree'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:372:in `find_resource_set'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:245:in `create_resource'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:34:in `block (2 levels) in process'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:107:in `run_callbacks'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:33:in `block in process'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:99:in `run_callbacks'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/processor.rb:32:in `process'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/operation.rb:12:in `process'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:140:in `process_operation'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:110:in `block (3 levels) in process_request'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/request_parser.rb:32:in `each'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:97:in `block (2 levels) in process_request'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:99:in `run_callbacks'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:96:in `block in process_request'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:127:in `block (2 levels) in process_operations'
/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.7/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.8.7/lib/active_record/transactions.rb:209:in `transaction'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:126:in `block in process_operations'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:99:in `run_callbacks'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:125:in `process_operations'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:95:in `process_request'
/app/vendor/bundle/ruby/3.2.0/gems/jsonapi-resources-0.10.7/lib/jsonapi/acts_as_resource_controller.rb:31:in `create'
/app/vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/app/vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.7/lib/abstract_controller/base.rb:215:in `process_action'
/app/vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.7/lib/action_controller/metal/rendering.rb:165:in `process_action'
/app/vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.7/lib/abstract_controller/callbacks.rb:234:in `block in process_action'
/app/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
resource:
class AuthorizeResource < JSONAPI::Resource
model_name 'AuthorizeV2'
model_hint model: AuthorizeV2, resource: :authorize
attributes [LIST OF ATTRIBUTES]
end
model:
class AuthorizeV2
include ActiveModel::Model
attr_accessor [LIST OF ATTRIBUTES]
end
- 主要语言
- Ruby
- 星标
- 2.3k
- 派生
- 546
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
JSONAPI-Resources/jsonapi-resources 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 3/5 1-2 天 新手友好度 50/100
JSONAPI-Resources/jsonapi-resources#1488 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 42/100
JSONAPI-Resources/jsonapi-resources#1479 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 30/100
JSONAPI-Resources/jsonapi-resources#1477 · 3 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 45/100
查看 JSONAPI-Resources/jsonapi-resources 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 88/100
-
バグ
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 2/5 1-3 小时 新手友好度 75/100
voxpupuli/puppet-epel#186 · 1 条评论 ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) 未关闭Bug Frontend
难度 2/5 1-3 小时 新手友好度 78/100