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

Transition class generated for mongoid is broken #29

Closed
tomclose opened this issue Mar 19, 2014 · 2 comments · Fixed by #156
Closed

Transition class generated for mongoid is broken #29

tomclose opened this issue Mar 19, 2014 · 2 comments · Fixed by #156

Comments

@tomclose
Copy link
Contributor

Using the transition class generated for the mongoid adapter will lead to errors like:

NameError: undefined method `statesman_metadata' for class ...

This is because the include Statesman::Adapters::MongoidTransition tries to alias statesman_metadata, which isn't defined at that point.

A short term fix is to move this line below field :statesman_metadata:

class OrderTransition
  include Mongoid::Document

  field :to_state, type: String
  field :sort_key, type: Integer
  field :statesman_metadata, type: Hash

  # this has to be after the statesman_metadata declaration
  include Statesman::Adapters::MongoidTransition
  # ....

A longer term solution could involve declaring the fields in Statesman::Adapters::MongoidTransition module, similar to how it is done here: https://github.com/aq1018/mongoid-history/blob/master/lib/mongoid/history/tracker.rb.

@tomclose
Copy link
Contributor Author

Actually this issue, #27 and #28 are all fixed by just removing the line include Statesman::Adapters::MongoidTransition.

It seems that Statesman::Adapters::MongoidTransition is incompatible with the mongoid generator.

@greysteil
Copy link
Contributor

@tomclose - sorry this took so long!

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.

2 participants