Best way to keep DRY

Hello folks,

I have models called Address and Cart and both have their needed
RESTful actions in place. Now there’s a third model called Despatch
which assigns the Cart’s contents to a chosen Address.

Ideally then, to keep DRY, I’d like to rely on my Address and Cart
controllers for:

  1. choosing an Address as a recipient
  2. displaying the Cart and allowing the user to make any modifications
    to its contents

before having my Despatch controller create the despatch.

My plan is to:

  1. have the Despatch controller set a session variable to indicate that
    a despatch is being done

  2. have the Address and Cart actions check that variable and alter
    their displays accordingly, ie Address index will display a select as
    recipient
    link in addition to the usual CRUD links.

  3. have each step in the process point to my Despatch controller’s
    new action, with a params variable to indicate which step the user is
    at, ie choosing recipient (redirect_to addresses_path), modifying cart
    (redirect_to cart_path).

  4. the last step will then be a link to Despatch’s create action, which
    will create the Despatch, empty the Cart and clear the session variable.

Does anyone know of a cleaner way of pulling this off?

Thanks in advance.

Franz