views:

105

answers:

1

I've been trying to implement a guided (wizard-like) interface to collect information to populate several models. I've found a decent amount of information on the various state machine plugins, but only one example on how the state machine can be used to control the view. (The Advanced Rails Recipe book from Pragmatic Programmers).

I'm convinced there has to be several ways to integrate a state machine with a view, and possibly a better way than the helper method in the Rails Recipe book.

Can anyone provide any links or info on how they implement state machines into their views?

Thanks!

+2  A: 

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

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

and use it with a regular url helper:

redirect_to wizard_url(:state => @user.registration_state)
Elad Meidar
sounds promising! I'll give it a shot.Thanks!!
Frank
I'm getting caught up on how to have more than one action for the route. I can't have multiple lines with different actions, because it will default to the top most one. I think what I'd want to avoid is having each state to be handled by the same action and have the same view code.
Frank
a little more detail from Elad: http://gist.github.com/199330
Frank