-
Notifications
You must be signed in to change notification settings - Fork 82
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
enum support #13
Comments
@renchap this is probably a problem for the parent project state_machines. I think you need to simple remove your state_machine requires a string |
@renchap, so, you have integers in your base? state_machine :status, attribute: :my_integer_status_id, initial: :parked do
state :parked, value: 0 # from enum
state :idling, value: 1 # from enum
event :ignite do
transition :parked => :idling
end
# ...
end |
FWIW, I think this adapter could add some nice support for ActiveRecord::Enum that would allow it to coexist. In short, it could detect if there is an existing enum defined for the state machine column, and then:
This should effectively allow people to have both an enum and state machine definition for the same column. Now the questions are: Is this worth doing? Are there convincing reasons to keep the enum definition even after adding a state machine? Is the behavior of the shared methods consistent between the two? |
In an existing model, my state column is a Rails enum and using state_machine on this column generates some warnings (and probably does not work) :
I am migrating from aasm and this is a nice feature I miss.
The text was updated successfully, but these errors were encountered: