JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Error "undefined method 'where' for" error on ActiveModel based resource
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.3k
- Forks
- 546
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit jsonapi/active_relation_resource.rb, insbesondere mit apply_filter und apply_filters, und verwende die gemeldete Änderung von JSONAPI Resources 0.9.12 zu 0.10.7 sowie das reine ActiveModel-Beispiel AuthorizeV2, um den Fehler zu reproduzieren. Vergleiche das Verhalten mit einer auf ActiveRecord basierenden Resource und definiere einen Regressionstest, der erfolgreich ist, sobald das Filtern einer ActiveModel-Resource nicht mehr den gemeldeten Fehler auslöst.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rails, ruby
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100