Forum: Ruby on Rails Extending a wizard

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2009-01-11 15:04
(Received via mailing list)
Hi,
I've created a simple wizard that collects data in 3 steps and then
posts it
to a Create action.

Validation is only performed when the data is posted. However, I would
like
the individual steps to be validated as well. Any ideas on this one?

Example:
Step 1
 Name
 Email
 Email (confirm)

Is there a generic way to let ActiveRecord validate the individual
fields of
a Model Object instead of the entire thing?

CmdJohnson
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-11 15:20
(Received via mailing list)
On 11 Jan 2009, at 14:04, Commander Johnson wrote:

> Step 1
>  Name
>  Email
>  Email (confirm)
>
> Is there a generic way to let ActiveRecord validate the individual
> fields of a Model Object instead of the entire thing?
>
The if/unless options on validates_* may be of interest.

Fred
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2009-01-16 22:28
(Received via mailing list)
Could you please post some code to explainify?

On Sun, Jan 11, 2009 at 3:20 PM, Frederick Cheung <
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-16 23:58
(Received via mailing list)
On 16 Jan 2009, at 21:27, Commander Johnson wrote:

> Could you please post some code to explainify?
>
validates_foo :if => :bar

will run that validation only if the bar method returns true. so you
can conditionalize your validations on anything you want.

Fred
This topic is locked and can not be replied to.