The Wizard Generator is a Rails application that generates wizards, forms and ActiveRecord objects.
JavaScript Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Rails Wizard Generator
August 2009

The Rails Wizard Generator is a Rails application generator 
that creates Rails applications based upon an XML application 

It can be used to:

 - Generate a functioning Rails application containing user-specified 
   forms and wizards

 - Generate an integrated set of Rails models, DB schema and 
   controllers (without any wizard or form views), including support 
   for ActiveRecord relationships between objects.

In particular, the generator creates:

 1) Rails MVC components (models, views and controllers) as an 
    alternative to traditional Rails scaffolding. Unlike Rails 
    scaffolding, it is possible to specify complete objects, along 
    with relationships between multiple objects, and then generate 
    a complete set of Rails MVC framework componentry in a single step.  

    Each object's attribute (column) can also contain range validation 

 2) Wizard views - the generator creates a set of wizards as RHTML 
    view files, and supports a full range of form field types.

 3) Form views - the generator creates a set of HTML forms as RHTML 
    view files, and supports a full rnage of form field types.

The generator may also be used simply to generate a complex set of 
Rails models and controllers, along with an integrated schema.

The generators takes as input an XML-based "specification" file, 
then generates the Rails application, objects, wizards and forms 
based upon these specifications.

The following wizard and form fields are supported:

	textfield - rails text_field
	textarea - rails text_area
	password -  rails password
	date - rails date 
	calendar - javascript calendar button
	richtext - javascript-based control for formated text
	actions - links for move to other steps

The generated wizard and forms-based application can be customized 
with your own CSS templates.  The generator uses the Liquid Template 

- Copy this application to your Rails development environment

$ git clone git://

$ cd generator (directory where generator was installed)

- Edit the config/database.yml to use MySQL or SqlLite 
  (as appropriate for your environment)

$ cd config
$ vi database.yml  (use your favorite editor here)
$ rake db:create
$ rake db:migrate
$ rake gems:install

- Create your application's XML specification

$ cd ../defs

$ cp test.xml myapp.xml

$ vi myapp.xml  (modify app definition as appropriate)

- Run the Rails Wizard Generator application using Rails server

$ cd .. (to your generator app directory)

$ ruby script/server  (run the Rails server)

- From Web browser, generate the application

Click the "generate" link
(wait while generation takes place...)

Your generated application is now located in the directory:


Please note that a complete Rails application has been generated, 
including database schema and live database tables, along with 
all required Rails MVC framework components for this application.

- Test your newly-generated application

(stop the Rails server)

$ cd output/myapp       (your generated application directory)

(optional - edit the config/database.yml file for your DB)

$ rake db:migrate

$ ruby script/server    (start up your new Rails application)

Connect with web browser to your new Rails application

The Rails application that is generated can then be further 
customized in whatever way you choose.  For example, you probably 
want to add your own CSS style and layout that creates a more 
appropriate appearance than the generic HTML look of the generated app.

You may also use the Rails Wizard Generator to create a holistic 
set of integrated Rails models and controllers (without the wizard 
or form views), along with a corresponding database schema that will 
be incorporated into some other, existing application (vs. using 
traditional Rails scaffolding).

Generator Description and Instructions

To generate project you need create a definition file in /defs 
directory (see the example test.xml in /defs directory)

To customize project, create directory in /templates/{appdir} and 
copy from /templates/app

/templates/app/views/controls -> /templates/{appdir}/views/controls
  -> /templates/{appdir}/views/layouts/application.html.erb

Place custom images in /templates/{appdir}/images
create/change css application.css in  

For custom form and wizard templates copy
  ->  /templates/{appdir}/views/form.erb.template

  -> /templates/{appdir}/views/wizard.erb.template

Template language based on liquid template engine 

It's a simple template engine for easier template understanding 
and editing.

Run generator web application (run: script/server) and then 
go to http://localhost:3000/  

You will see list of current xml definition files or run rake 
task which generate all projects (run: rake generator:run)

projects will be generated in output directory

Last step is deploy project to server and after change 
config.database.yml db data according server db settings, 
then run rake db:migrate to create and populate db tables

Xml definitions:
All rails associations supported: belongs_to,has_one,has_many. 
class attribute is class param for association

Name is field name in db and type is any rails migration types
(string,text,date,datetime,boolean etc)

field.params is params for migration, as :limit,:default,:null

Type is rails validation method name without validate_ as 
"presence_of" will generated to "validate_presence_of", also 
there are addition validations as email format and phone format 

Fields is comma separated list of fields for validation
validator.params: some rails validation methods required 
additional params as maximum or within for validate_length_of
If predefined data is required for some objects then it can be 
defined in data, see object Country definition as an example

Name is name of step(required)
object defines which object will be used in form(form_for rails)
object can be overwriten for control by object which in 
relationship with main object, see account_type of Account Info


Supported field types:

no input: text,image

  textfield - rails text_field
  textarea - rails text_area
  password -  rails password
  date - rails date 
  calendar - javascript calendar button
  richtext - javascript based control for enter formated text
  actions - links for move to other steps

name: field name in db

Basically control html attributes as style,class etc. can be 
defined here, but some controls other params support rails control 
specific params as date (start_year, end_year, discard_day, 
discard_month,discard_year,order) and actions 

for text is text in this control
for image is src of image in /public/images
for other controls is default value
for select and radio is comma separated list for options
also select's options can be defined by datasource param where format: 

{object}.{field for option value}:{field for option text} 
see country select for example

Generator XML Specification - Example

Applications are specified with an XML file definition, making it easy
to see all of your application objects, relationships, wizard and form
definitions together (you can easily print the XML file out to desk
review it before generating your app).

The following is an example of a relatively simple application spec:

<?xml version="1.0" encoding="UTF-8"?>

<appdef appname="Test Wizard Application" appdir="wiz">

    <classdesc>Account class describes a master user's (admin user) account and its settings</classdesc>
      <relationship type="has_many" classname="Project">projects</relationship>
      <relationship type="has_one" classname="Account">account</relationship>
      <field name="username" type="string">
          <param name="limit">100</param>
      <field name="password" type="string" />
      <field name="first_name" type="string" />
      <field name="last_name" type="string"/>
      <field name="email" type="string" />
      <field name="dob" type="datetime"/>
      <field name="bio" type="text"/>
      <field name="sex" type="string" >Male</field>
      <field name="avatar" type="string"/>
      <field name="is_active" type="boolean"/>
      <validator fields="username" type="presence_of">
          <param name="message">required</param>
      <validator fields="password,first_name,last_name" type="presence_of"></validator>
      <validator fields="username" type="length_of">
          <param name="maximum">30</param>
          <!-- <param name="within">5..30</param> -->
      <validator fields="sex" type="inclusion_of">
          <param name="in">Male,Female</param>
      <validator fields="email" type="format_of_email"></validator>
      <!-- <validator field="" type="format_of_phone"></validator> -->
      <!-- <validator fields="number" type="numericality_of"></validator> -->      
      <!-- <validator field="is_active" type="acceptance_of"></validator> -->

      <relationship type="belongs_to" classname="User">user</relationship>
      <field name="account_type" type="string" maxlength="10">Standard</field>
      <field name="membership" type="float"/>
      <validator fields="account_type" type="inclusion_of">
          <param name="in">Standard,Premium,Free</param>
    <classdesc>Project class</classdesc>
      <relationship type="belongs_to" classname="User">user</relationship>
      <field name="title" type="string" maxlength="100"/>
      <field name="descr" type="text"/>


<!-- Wizards -->

<wizard name="New Account">
<title>New Account</title>
<overview>Text describing the purpose of this wizard</overview>
<wizard-step has-finish-button="false" name="Account Info" object="User">
  <title>Account info</title>
    <user-control type="text"><value>Fill user account info</value></user-control>
    <user-control type="textfield" name="username" label="Username:">
        <attribute name="maxlength">16</attribute>
        <attribute name="class">red-border</attribute>
    <user-control type="password" name="password" label="Password:"></user-control>
    <user-control type="textfield" name="email" label="Email:"></user-control>
    <user-control type="select" name="account_type" label="Account type:" object="Account">
    <user-control type="checkbox" name="is_active" label="Is active:"><value>true</value></user-control>  

<wizard-step has-finish-button="true" name="Personal Info" object="User">
  <title>Personal info</title>
  <user-control type="text">This text explains to the user what this wizard step is about and what the user is expected to do in this step. This text is shown to the user of the wizard in appropciate "div" tag area.</user-control>
  <user-control type="textfield" name="first_name" label="First name:">
      <attribute name="maxlength">50</attribute>
  <user-control type="textfield" name="last_name" label="Last name:"></user-control>
  <user-control type="textarea" name="bio" label="Bio:"></user-control>
  <user-control type="date" name="dob" label="Dob:"></user-control>
  <user-control type="radio" name="sex" label="Sex:"><value>Male,Female</value></user-control>
  <user-control type="file" name="avatar" label="Avatar image:"></user-control>

<!-- <wizard-step>
  <title>Choose Project Operation</title>
  <user-control type="text" name="instructions" userlabel="Instructions:">What do you want to do with your Projects?</user-control>
  <user-control type="listbox" name="operation" userlabel="Choose one:">"create" => "Create new project", "edit" => "Edit existing project", 
                                                                        "delete" => "Delete a project"</user-control>
  <wizard-branch user-control="operation">
      <case select="create" wizard="create-proj"></case>
      <case select="edit" wizard="create-proj"></case>    
      <case select="delete" wizard="create-proj"></case>
</wizard-step> -->

<wizard-step has-finish-button="true" name="Another">
  <title>Another step</title>
    <user-control type="text">Some text</user-control>
    <user-control type="image">tree.jpg</user-control>
    <user-control type="actions">
        <attribute name="account_info">First step</attribute>
        <attribute name="personal_info">Personal Info</attribute>
<wizard-step name="Finish">
    <user-control type="text">Some text</user-control>

<!-- The generated Ror "template" for each wizard contains "Back" and "Next" buttons.
     A "Cancel" button is provided on each wizard page.
     An appropriate "Step X of NN" is shown on each wizard page, showing the page "X" that user is currently on out of maximum "NN" wizard pages.


<!-- forms are used to edit database table records, or gather user input and then POST to another page to process user input -->

<form name="User" title="View/Edit User" object="User"> <!-- or url="" -->
  <user-control type="textfield" name="username" label="Username:"/>
  <user-control type="password" name="password" label="Password:"></user-control>
  <user-control type="textfield" name="first_name" label="First name:">
       <attribute name="maxlength">50</attribute>
   <user-control type="textfield" name="last_name" label="Last name:"></user-control>
   <user-control type="textarea" name="bio" label="Bio:"></user-control>
   <user-control type="date" name="dob" label="Dob:"></user-control>
   <user-control type="radio" name="sex" label="Sex:"><value>Male,Female</value></user-control> 



Copyright (c) 2009 ConXentric, Inc., licensed under the GNU GPL License