RESTful design question


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

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

Thanks in advance.


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.

Free Ruby & Rails screencasts