Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying a polymorphic association doesn't work #291

Open
zedtux opened this issue Dec 20, 2022 · 1 comment
Open

Querying a polymorphic association doesn't work #291

zedtux opened this issue Dec 20, 2022 · 1 comment
Labels
bug Something that was working before, dont anymore.

Comments

@zedtux
Copy link
Collaborator

zedtux commented Dec 20, 2022

Model.where(associatable: item).first doesn't work and raise an error.

@zedtux zedtux added the bug Something that was working before, dont anymore. label Dec 20, 2022
@arabakevin
Copy link

Here, we can see the error

rails_1      | 
rails_1      | NoMethodError (undefined method `id' for nil:NilClass):
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/document/association/belongs_to.rb:103:in `cast_attr'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/document/association.rb:27:in `association_user_to_model_cast'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:200:in `cast_key_path'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:96:in `simplify'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:48:in `map'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:48:in `simplify'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:48:in `map'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:48:in `simplify'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:19:in `merge_where_ast'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:39:in `call'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:39:in `block in merge!'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:36:in `each'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:36:in `merge!'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/eager_load.rb:16:in `merge!'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/cache.rb:24:in `merge!'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/extend.rb:15:in `merge!'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:45:in `merge'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/core.rb:56:in `chain'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/criteria/where.rb:11:in `where'
rails_1      | /usr/local/bundle/gems/nobrainer-0.43.0/lib/no_brainer/document/criteria.rb:16:in `where'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that was working before, dont anymore.
Projects
None yet
Development

No branches or pull requests

2 participants