Skip to content

jeffp/wizardly-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wizardly-examples

Examples for jeffp-wizardly gem

github.com/jeffp/wizardly

Setup

clone the directory

git clone git://github.com/jeffp/wizardly-examples.git

change to the directory and install the gems

rake gems:install

build the database. The examples currently use Sqlite3 (you’ll need it installed or change the database to your preference)

rake db:create
rake db:migrate

start the server

./script/server

Examples

Standard User Signup Wizard

  • CreateUsers

  • SignupController

  • UserSignup

  • User

This example creates a User record from a wizard in three steps. The steps are defined by ‘validation_group’ macros on the UserSignup model (which inherits from the User class). All validation is defined in the User class.

The SignupController class acts wizardly for UserSignup. In addition, it defines four callback macros for additional processing in the wizard flow.

Wizard for STI Model

  • CreateContributors

  • ContributorController

  • ContributorWizard

  • Contributor

  • Donator

  • Volunteer

This example demonstrates how wizardly is used to generate a wizard with two different paths for an STI model. The base model is the Contributor class and both Volunteer and Donator inherit from the Contributor class. To handle the wizard for the STI model, a fourth class, ContributorWizard, subclasses the Contributor class and defines the validation groups. It also sets the STI inheritance_column to a non-existant column so that the wizard can dictate the final model based on user input.

The ConntributorController acts wizardly for the ContributorWizard model, and defines two routes to completion depending on whether the user chooses :volunteer or :donator in the :participation page. Callback macros on_next(:participation) and on_next(:donation) are used to control the progression path of the wizard based on user choice. Note the progression is only managed going forward because the wizardly gem manages the correct backward progression (from :back buttons) based on previous forward progression.

The on_finish(:finish) callback macro is called when the user finished the final page and clicks the :finish button. It sets the :type column for the STI model before the record is created.

Wizard for Resource and Image_submit tags

  • CreatePolls

  • PollsController

  • PollWizardController

  • Polls

This example demonstrates how to replace a resource’s new form with a wizard. When ‘new poll’ is clicked on th resource’s index page, PollWizard controller is called. The PollsWizradController uses the wizard’s global on_completed callback macro to redirect to the resource controller once the resource has been committed to the database.

This example also demonstrates the wizardly_image_submit helper.

Wizard with User Defined Buttons

This example demonstrates customizing the five default buttons and adding a custom button

About

Examples for the jeffp-wizardly gem

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published