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

Calling .empty? for nil from aasm_ensure_initial_state with Mongoid #793

Open
zedtux opened this issue Aug 30, 2022 · 1 comment
Open

Calling .empty? for nil from aasm_ensure_initial_state with Mongoid #793

zedtux opened this issue Aug 30, 2022 · 1 comment

Comments

@zedtux
Copy link
Contributor

zedtux commented Aug 30, 2022

Describe the bug
Since the commit 1c5117, and starting with AASM version 5.0.5, AASM is no more compatible with Mongoid aliased fields.

You can find a code example from #535 which makes AASM breaking with :

      NoMethodError:
        undefined method `empty?' for nil:NilClass
      # /usr/local/bundle/gems/aasm-5.0.5/lib/aasm/persistence/mongoid_persistence.rb:109:in `block in aasm_ensure_initial_state'
      # /usr/local/bundle/gems/aasm-5.0.5/lib/aasm/persistence/mongoid_persistence.rb:103:in `each'
      # /usr/local/bundle/gems/aasm-5.0.5/lib/aasm/persistence/mongoid_persistence.rb:103:in `aasm_ensure_initial_state'
      # /usr/local/bundle/gems/mongoid-7.5.1/lib/mongoid/interceptable.rb:122:in `run_callbacks'
      # /usr/local/bundle/gems/mongoid-7.5.1/lib/mongoid/document.rb:116:in `block in initialize'
      # ...

To Reproduce
Steps to reproduce the behavior:

  1. Create a model using a Mongoid aliased field like in Mongoid initial value not setted (new case or regression) #535
  2. Try to call .new on it
  3. See error

Expected behavior
The model initialization should work without any errors.

@bk-one
Copy link

bk-one commented Feb 2, 2023

+1

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

No branches or pull requests

2 participants