In the model
def validate
validate1
validate2
validate3
validate4
end
def validate1
# Check things that can be validated in step1
end
def validate2
# Check things that can be validated in step2
end
def validate3
# Check things that can be validated in step3
end
def validate4
# Check things that can be validated in step4
end
Store the data in the session. That way the end user cannot modify it
along the way.
--
-- Tom Mornini
On Oct 19, 2005, at 11:16 AM, Anatol Pomozov wrote:
> Hi, all.
>
> I need to implement registration wizard for ror app. Nothing
> special just several sequent screens
> 1. Please enter your name, login password, email
> 2. enter date of birth, location
> 3. Something else
> It is rather usual situation.
>
> User comes to first screen and fills field press submit. Method
> ''step1'' of register controller invoked.
> The problem there with validation: I need only validate specific
> fields, not all.
> I am using now following code
> @user = Character.new(params[:character])
> @user.errors.add(''plan'') unless 1..4 ===
@character.plan
> @user.errors.add_on_blank(%w(firstname lastname country))
> But I fell like it is violation of DRY principle because I already
> have validate rules in model.
>
> What is the best pattern in this situation??
>
> And one more question: where better to save data between wizard
> steps?? In session or save to hidden fields? What do you advise me??
> --
> anatol
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>