[ANN] ActionSequence 1.0.1 - Multipage Form Routing

Hi Ruby on Rails folks,

I wrote ActionSequence
(http://github.com/boof/action_sequence/tree/master
)
for my company to better handle multipage forms. It comes with a DSL for
creating a sequence.

Example

class LinksController

 before_filter :link_persistence_implementation #...

 sequence :link_wizard do
   # 1. Step
   enter_description { |s| s.next if @link.valid? :description }
   # 2. Step
   enter_path do |s|
     if params[:back] then s.previous
     elsif @link.valid? :shortcut then s.next
     end
   end
   # 3. Step
   select_target do |s|
     if params[:back] then s.previous
     elsif @link.valid? :path and @link.save then s.next
     end
   end
 end

 def new
   walk_link_wizard_sequence :enter_description
 end
 def edit
   walk_link_wizard_sequence :enter_description
 end

 before_filter :walk_link_wizard_sequence, :only =>

[:create, :update]

 def create
   unless link_wizard_sequence.finished_with? @step
     render :action => :new
   else
     redirect_to link_path(@link)
   end
 end
 def update
   unless link_wizard_sequence.finished_with? @step
     render :action => :edit
   else
     redirect_to link_path(@link)
   end
 end

end

I hope this source is more or less self-explanatory.

The step, if not otherwise defined, is placed in @step. It’s
identified by
params[:step].

You can select another walker variable by passing a second argument to
the
builder, for example sequence :another, :page. In this case the step
is
stored in @page and identified by params[:page].

By default the first step is choosen.

A step has a name, for example :enter_description and an index (here: 1)
which can be used in your view to select a partial.

The plugin should be fairly easy to hack to fit your needs.

Cheers
Florian

Source on GitHub: http://github.com/boof/action_sequence/tree/master
I work @ Fork Unstable Media GmbH - we hire!

TODO

  • Documentation

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs