# RESTful design question

**URL:** <https://www.ruby-forum.com/t/restful-design-question/149093>\
**Category:** Rails\
**Created:** [September 20, 2008, 8:39am UTC](https://www.ruby-forum.com/t/restful-design-question/149093 "2008-09-20T08:39:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [September 20, 2008, 8:39am UTC](https://www.ruby-forum.com/t/restful-design-question/149093/1 "2008-09-20T08:39:16Z")

</div>

Hello-

I’m working on an e-commerce app. Specifically, I’m working on how  
addresses are managed. An Order has\_one Address. A User has\_many  
Addresses. I defined some routes that look like this:

map.resources :orders, :has\_one =\> [:address, :credit\_card]

map.resources :users do |user|  
user.resources :addresses  
user.resources :credit\_cards  
end

The issues is that my orders route is accessing the address like a  
singleton and my users route is accessing it like a normal resource.

What is the best way to handle this? Should I have one controller that  
can be used in both situations? Should I create two controllers, one  
singleton and one regular? Any other approaches that I might be  
missing?

Thanks in advance.

Regards,  
Eric

---

<div class="post-metadata">

**Author:** ![snowbird122](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@snowbird122](https://www.ruby-forum.com/u/snowbird122)\
**Post date:** [September 21, 2008, 9:24am UTC](https://www.ruby-forum.com/t/restful-design-question/149093/2 "2008-09-21T09:24:49Z")

</div>

In my ecommerce app I have customer model which has address  
attributes. The order model has foreign key to customers table.

There are several ways to do it. I let the screens drive the design.  
Pick the one that makes sense in your app.

[Http://www.rubyplus.org](Http://www.rubyplus.org)  
Free Ruby & Rails screencasts

On Sep 19, 2008, at 11:38 PM, emarthinsen
