Forum: Ruby on Rails Making things DRY: RESTful address controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Marcelo de Moraes S. (Guest)
on 2009-02-18 04:53
(Received via mailing list)
Hello list,

I'm developing an e-commerce application, and the Checkout controller
has an
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?


This topic is locked and can not be replied to.