Skip to content

Commit

Permalink
fixes multi-wizard bug; adds complete_wizard method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffp committed Aug 18, 2009
1 parent 9b9fb97 commit df1c885
Show file tree
Hide file tree
Showing 54 changed files with 786 additions and 168 deletions.
44 changes: 41 additions & 3 deletions README.rdoc
Expand Up @@ -34,7 +34,7 @@ Features include:

Put the following in your application's config block in config/environment.rb

config.gem 'jeffp-wizardly', :lib=>'wizardly'
config.gem 'jeffp-wizardly', :lib=>'wizardly'

and run the install gems rake task on your application

Expand All @@ -44,6 +44,20 @@ For any rails app, run the following to install wizardly rake tasks (optional)

./script/generate wizardly_app

== Recommendations

Wizardly uses sessions. It is recommended you use a session store other than the
default cookies store to eliminate the 4KB size restriction. To use the active
record store, add this line to your environment.rb

config.action_controller.session_store = :active_record_store

And set up the sessions table in the database

rake db:sessions:create
rake db:migrate

Use the MemCached session store for higher performance requirements.

== Example

Expand All @@ -69,7 +83,9 @@ Step 3: Generate a 'wizardly' scaffold for your controller.

You are ready to go.

General usage and configuration of wizardly follows.
General usage and configuration of wizardly follows. See the examples at

http://github.com/jeffp/wizardly-examples

== Usage

Expand Down Expand Up @@ -312,6 +328,23 @@ call back for this.
end
end

=== Completing the Wizard Programmatically

Perhaps you want to complete a wizard based off of a test instead of a button
click. You can do this in your callbacks by calling the +complete_wizard+ method.

on_next(:step4) do
if (test_radio_button)
complete_wizard
end
end

Complete wizard will save the model and redirect to the :completed redirect setting.
You can change the redirect dynamically by passing it to the method.

complete_wizard(some_model_path)


=== Creating Scaffolds

Wizard scaffolds can be created for any wizardly controller (one using the acts_wizardly_for
Expand All @@ -329,14 +362,19 @@ each page.

./script/generate wizardly_scaffold controller_name --underscore

You can create a scaffold using image_submit_tag by doing the following:

./script/generate wizardly_scaffold controller_name --image_submit

Default button images are provided under the public/images/wizardly/ directory.

== Advanced Configuration

To be provided

== Testing

Testing uses RSpec and Webrat. Make sure you have those gems installed. Then
Testing uses RSpec and Webrat. Make sure you have the gems installed. Then
to test the development code run the following:

rake spec:all
Expand Down
11 changes: 9 additions & 2 deletions Rakefile
Expand Up @@ -39,16 +39,23 @@ require 'spec/rake/spectask'

namespace :spec do
desc "Run all specs"
task :all=>[:macro, :gen, :scaffold, :callback, :callback2, :callback3, :datamodes, :sandbox, :session]
task :all=>[:macro, :gen, :scaffold, :callback, :callback2, :callback3, :persist, :sandbox, :session]
desc "Test the MacroController"
Spec::Rake::SpecTask.new(:macro) do |t|
t.spec_files = FileList['spec/integrations/macro_spec.rb']
t.libs << 'lib' << 'spec' << 'spec/integrations'
t.spec_opts = ['--options', 'spec/spec.opts']
t.rcov = false
end
desc "Test the DataModes2Controller"
Spec::Rake::SpecTask.new(:persist2) do |t|
t.spec_files = FileList['spec/integrations/data_modes2_spec.rb']
t.libs << 'lib' << 'spec' << 'spec/integrations'
t.spec_opts = ['--options', 'spec/spec.opts']
t.rcov = false
end
desc "Test the DataModesController"
Spec::Rake::SpecTask.new(:datamodes) do |t|
Spec::Rake::SpecTask.new(:persist) do |t|
t.spec_files = FileList['spec/integrations/data_modes_spec.rb']
t.libs << 'lib' << 'spec' << 'spec/integrations'
t.spec_opts = ['--options', 'spec/spec.opts']
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/data_modes2_controller.rb
@@ -0,0 +1,7 @@
class DataModes2Controller < ApplicationController

act_wizardly_for :user, :persist_model=>:per_page, :form_data=>:sandbox,
:completed=>{:controller=>:main, :action=>:finished},
:canceled=>{:controller=>:main, :action=>:canceled}

end

0 comments on commit df1c885

Please sign in to comment.