I am using AASM with rails and I have been searching around for a solution for my problem, i need to make a state machine system configured by user.
Imagine this scenario:
- the user visit the States CRUD page
- the user creates a new state X and a new state Y for Project model
- the user creates a transition from state X to state Y for Project model
- the user visits Project show page
- the user can switch between the states he created for Project model
Is there an easy way to implement these cases using AASM?
I imagined something like this:
class Project < ActiveRecord::Base
include AASM
aasm do
State.where(model_name: 'Project').each do |database_state|
state database_state[:name], database_state[:initial]
end
Event.where(model_name: 'Project').each do |database_event|
...
end
end
end