Best Practices for Multi-step Record Creation


#1

class Activity
has_many :locations

In activities#new, I navigate away and select a location (among other
things) on a map. At this point, the @activity is still missing
attributes and is invalid. What is the best practice for preserving
the state of this invalid record until I return to it? I could:

  1. Make all validations conditional depending on the state of the
    record. But this seems pretty clunky. I want to be able to call
    #valid? and get the correct answer.

  2. Create a supper class RawActivity with no validations and then let
    Activity inherit from it when it’s ready to be saved. This also looks
    like a messy solution.

  3. Dump all the @activity attributes into the session, reconstitute
    them in the Location controller. Find the location, dump the
    @location attributes into session. Go back to the Activity controller
    and stitch it all together. Yuck.

  4. Render the form in javascript and hide everything until it’s ready
    to be saved.

Am I missing something? What’s the best practice?