I’m developing an e-commerce application, and the Checkout controller
edit_address and create_addresses method. I’m not expert in any
RESTful-based architecture (including the Rails implementation) but this
just doesn’t feel right. I would rather have a Addresses controller to
create and edit addresses, create a resource out of it, and nest it as
needed for any other resource that needs it (by making it polymorphic,
something like this:
To edit an address, I would then just POST to
http://url/addresses/idinstead of POSTing to checkout/edit_address/.
Much simpler and DRY.
Would also clean up the checkout controller, removing from it the
responsibilities of editing addresses…
However, in one of the checkout steps, I need to create two addresses in
only one request (billing and shipping addresses) - as there is a screen
with two addresses forms so the user can input their addresses. These
addresses need to be created in the account (account has one billing
and has one shipping address). I would rather not create an
action in the addresses polymorphic controller, but I see no other way
receiving the input of this form and updating both addresses at the same
What do you think?