forked from akira/validationgroup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
29 lines (19 loc) · 1.09 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ValidationGroup
===============
When doing multipage forms that spread a models fields over several pages, validation becomes more difficult. We would like to validate each step of the form, however, the rails validation run validation on all the fields. This plugin enables you to define validation groups with certain fields, and then only run validation on those groups.
To install, type: git clone git://github.com/akira/validationgroup.git vendor/plugins/validationgroup && rm -rf vendor/plugins/validationgroup/.git
Home page for plugin is: http://alexkira.blogspot.com/2007/09/rails-validation-using-validation.html
Example
=======
class User < ActiveRecord::Base
validates_presence_of :name, :description, :address, :email
validation_group :step1, :fields=>[:name, :description]
validation_group :step2, :fields=>[:address]
end
This will run validation on :step1 fields
@user = User.new
@user.enable_validation_group :step1
@user.valid?
You can later disable validation groups by calling:
@user.disable_validation_group
Copyright (c) 2007 Alex Kira, released under the MIT license