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

Issue with the polymorphism association #288

Closed
arabakevin opened this issue Aug 26, 2022 · 0 comments · Fixed by #289
Closed

Issue with the polymorphism association #288

arabakevin opened this issue Aug 26, 2022 · 0 comments · Fixed by #289

Comments

@arabakevin
Copy link

When I use a where on a model with polymorphic association i have an error

Inbox::Row.where(
          item: context.sub_item,
          module: 0,
          organization: context.organization,
          project: context.project
        ).first

In my model

    belongs_to :item, polymorphic: true

i have this error

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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant