Marcelo de Moraes Serpa
2009-Feb-18 02:52 UTC
Making things DRY: RESTful address controller
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: http://www.pathf.com/blogs/2008/07/drying-up-rails-controllers-polymorphic-and-super-controllers/). 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 address and has one shipping address). I would rather not create an edit_addresses action in the addresses polymorphic controller, but I see no other way of receiving the input of this form and updating both addresses at the same time. What do you think? Thanks, Marcelo. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---