乐者为王

Do one thing, and do it well.

使用wizardly插件创建multi-step wizard

wizardly是一个非常容易使用的创建multi-step wizard的Rails插件,只需要三步就可以。

安装插件:

1
2
gem install wizardly
script/generate scaffold user first_name:string last_name:string age:integer gender:boolean

第一步:

1
2
3
class User < ActiveRecord::Base
  validation_group :step1, :fields => [:first_name, :last_name]
  validation_group :step2, :fields => [:age, :gender]

第二步:

1
2
class UsersController < ApplicationController
  act_wizardly_for :user

第三步:

1
script/generate wizardly_scaffold users

现在你就可以通过访问http://localhost:3000/users/step1来查看效果了。

Comments