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

Initialization error with mongoid-3.1.0 #232

Closed
pmor opened this issue Feb 14, 2013 · 3 comments
Closed

Initialization error with mongoid-3.1.0 #232

pmor opened this issue Feb 14, 2013 · 3 comments
Assignees

Comments

@pmor
Copy link

pmor commented Feb 14, 2013

I just updated do mongoid-3.1.0 and I get this error on any state_machine I try to create. Classes without state_machine are working fine.

Exception: NoMethodError: undefined method `[]=' for nil:NilClass
--
0: [...]/mongoid-3.1.0/lib/mongoid/attributes.rb:171:in `block in write_attribute'
1: [...]/mongoid-3.1.0/lib/mongoid/threaded/lifecycle.rb:26:in `_assigning'
2: [...]/mongoid-3.1.0/lib/mongoid/attributes.rb:169:in `write_attribute'
3: [...]/mongoid-3.1.0/lib/mongoid/fields.rb:436:in `block (2 levels) in create_field_setter'
4: [...]/state_machine-1.1.2/lib/state_machine/machine.rb:1097:in `write'
5: [...]/state_machine-1.1.2/lib/state_machine/machine.rb:695:in `initialize_state'
6: [...]/state_machine-1.1.2/lib/state_machine/machine_collection.rb:31:in `block in initialize_states'
7: [...]/state_machine-1.1.2/lib/state_machine/machine_collection.rb:30:in `each_value'
8: [...]/state_machine-1.1.2/lib/state_machine/machine_collection.rb:30:in `initialize_states'
9: [...]/state_machine-1.1.2/lib/state_machine/integrations/mongoid.rb:375:in `initialize'

The exception is thrown here (/mongoid-3.1.0/lib/mongoid/attributes.rb:171:in `block in write_attribute')

attributes_before_type_cast[name.to_s] = value

because attributes_before_type_cast is nil

@pmor
Copy link
Author

pmor commented Feb 14, 2013

Also opened issue in mongoid: https://github.com/mongoid/mongoid/issues/2827

@obrie obrie closed this as completed in a8dff80 Feb 17, 2013
@obrie
Copy link
Member

obrie commented Feb 17, 2013

Thanks for reporting this! I've made a change to the Mongoid integration which will prevent issues like this from cropping up in the future -- this will make state_machine work on the unpatched version of Mongoid 3.1.0.

@pmor
Copy link
Author

pmor commented Feb 17, 2013

👍 Great!

@ghost ghost assigned obrie Feb 18, 2013
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