Any ideas for code representation when using state machines?

I am trying to implement a guided (magic) interface for collecting information to populate multiple models. I've found a decent amount of information on various state machine plugins, but just one example of how a state machine can be used to manipulate a view. (The Advanced Rails Recipe Book by Pragmatic Programmers).

I am convinced that there are several ways to integrate a state machine with a view, and perhaps in a better way than the helper method in the Rails recipe book.

Can anyone provide any links or information on how they implement state machines in their views?

Thank!

+2


source to share


1 answer


what about actions with the same names as your states? a named route with a state token can do the routing trick.

map.wizard 'wizard/:state', :controller => 'whatever', :action => 'whatever2'

      



and use it with the usual url helper:

redirect_to wizard_url(:state => @user.registration_state)

      

+2


source







All Articles