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

Feautre: transition from: [ARRAY] #396

Open
mehmetaydogduu opened this issue Mar 29, 2020 · 3 comments
Open

Feautre: transition from: [ARRAY] #396

mehmetaydogduu opened this issue Mar 29, 2020 · 3 comments

Comments

@mehmetaydogduu
Copy link

mehmetaydogduu commented Mar 29, 2020

For testing I define a rule from all states to all states.
all_states = %w[draft attempted leave success failed cancelled refunded]
transition from: :all_states, to: all_states
the code below not working because the from option not accepts array.
If it accept array we can have less lines.

@danwakefield
Copy link
Contributor

We unfortunately don't support this as it is ambiguous. You can instead do

all_states.each do |from_state|
  transition from: from_state, to: all_states
end

If you don't want to specify things explicitly.

@mehmetaydogduu
Copy link
Author

mehmetaydogduu commented Mar 30, 2020

Thank you. The case solved by loop. Right.

In reality it is looks very complicated. Even if I array them, they don't fit in one line. The entire file contains 74 transition from to lines. A part of file below. What can I do to visualize it?

  # time outs
  transition from: :processing_time_out, to: :refund
  transition from: :shipping_time_out, to: :refund
  transition from: :delivery_time_out, to: :refund

  transition from: :shipping_back_time_out, to: :confirmed
  transition from: :shipping_back_delivery_time_out, to: :confirmed

  transition from: :change_process_time_out, to: :refund
  transition from: :change_process_delivery_time_out, to: :refund

@mehmetaydogduu
Copy link
Author

Is there any way to use without initial state?
I have the error: Cannot transition from '' to 'success'

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