Search code examples
ruby-on-railsrubyruby-on-rails-plugins

Validation groups for wizard-style forms


can somebody explain me, how to do wizard-style forms with validations?

f.e.:

i have a appointment-model, which should include following data: name, starttime, endtime, address, city.

Now i want to have 3 actions for each datagroup:

  1. name
  2. start and enddate
  3. address-fields

each of them should be accessible (so AASM isn't an option I think -> model.wizard_step = 3 and generating the right view for this step isnt enough).

And each of them should have validations

  1. name shouldnt be nil
  2. startdate must not be after enddate
  3. addressfields must not be nil

but how do i save this object between the single steps, and how to build in this validations schemas/groups...?

heeelp.. thanks =)


Solution

  • You could use the Grouped Validations gem for this: https://github.com/adzap/grouped_validations