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:
- choosing an Address as a recipient
- 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:
-
have the Despatch controller set a session variable to indicate that
a despatch is being done -
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. -
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). -
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