Suggested pattern/approach for 'wizard' like interface?

61 views
Skip to first unread message

sherod

unread,
Jan 30, 2008, 5:00:02 AM1/30/08
to Ruby on Rails Oceania
Hi all.

Just wondering about a suggested pattern for dealing with a 'wizard'
style interface.

I want to take a user through an interview style Q&A data collection
process that results in the creation of a completed model persisted to
the database.

I can think of various approaches, but I cheerfully admit I'm not
exactly 100% on the rails way of doing things, so pointers to a
potential 'right' way would be good....


James Healy

unread,
Jan 30, 2008, 5:29:01 AM1/30/08
to rails-...@googlegroups.com
sherod wrote:
> Just wondering about a suggested pattern for dealing with a 'wizard'
> style interface.

The Advanced Rails Recipes beta book [1] has a wizard example that uses
a state machine. I haven't tried it myself, but it sounded interesting
when I skimmed it.

-- James Healy <jimmy-at-deefa-dot-com> Wed, 30 Jan 2008 21:27:55 +1100

[1] http://www.pragprog.com/titles/fr_arr

Hugh Evans

unread,
Jan 30, 2008, 6:09:59 AM1/30/08
to rails-...@googlegroups.com
Steven,

Combine it with the validatable plugin and your on a winner:

validatable.rubyforge.org

Hugh

sherod

unread,
Jan 30, 2008, 1:31:09 PM1/30/08
to Ruby on Rails Oceania
Book bought, pattern read. Looks like a goer! Thanks!

(Haven't looked at validatable yet, maybe on the train...)

ben wiseley

unread,
Jan 30, 2008, 1:55:34 PM1/30/08
to rails-...@googlegroups.com
The way I've been handling stuff like this (i.e. models that are gradually updated and want to use the validation stuff) is by doing things like

User model - mostly just has methods - no validations

UserPassword < User  - which has validations for password, confirm, etc.

UserProfile < User - which has first/last name required, etc.

Probably not ideal...

-ben

sherod

unread,
Jan 30, 2008, 3:25:10 PM1/30/08
to Ruby on Rails Oceania
acts_as_state_machine and validatable work like a treat.

From suggested answer to working prototype in 2 hours.... :)

It reminds me why I like this stuff.

Geoff Evason

unread,
Jan 31, 2008, 8:32:06 PM1/31/08
to Ruby on Rails Oceania
Another idea, which may or may not be applicable to your case but I
thought worth sharing...

I have a wizard for my project. Rather than creating a single object
it creates an entire hierarchy of related objects.

My wizard starts by creating a deep clone of an existing 'template'
tree, and the rest of the wizard just runs as edits/updates. This
allows me to get the validation on the updates and easily fill in
intelligent default values based on my template. This is probably
only useful for creating a collection of related objects at once using
a single wizard.
Reply all
Reply to author
Forward
0 new messages