Code for Concinnity


A Clean Approach to Partial Object Validation with Rails + Wicked Wizard

This is cleaner than the official method IMO, because it involves zero / minimal model object modification. The wizard logic clearly belongs to the controller only.

The basic ideas are:

  • Derive from the ActiveRecord
  • Override save to make Wicked behave. You can do arbitrarily complex thing there without wrangling with validation conditions.

Here’s the code:

Here is another version using a partial flag to persist the partial object in database:

Published by kizzx2, on February 6th, 2013 at 11:00 pm. Filled under: UncategorizedNo Comments

No comments yet.

Leave a Reply