1. I have a few tables: ''users'', ''shops'',
''addresses'', and ''pictures''.
2. Users and Shops will both use the addresses and pictures tables. I have
created several mapping tables:
addresses_shops
pictures_shops
addresses_users
pictures_users
3. Users CAN have many addresses and pictures (simple HABTM), but...
4. I''d like it if Shops _only_ could have one of each. Since both users
and
shops are accessing addresses and pictures, I can''t exactly use a
simple
''has_one'' relationship with regards to Shops (...right?)
5. As of right now, this is how I access the address of a shop:
@shop = Shop.find( id )
@address = @shop.addresses.first
...but I''d like to be able to do...
@shop = Shop.find( id )
@address = @shop.address
Is there a correct way to do this? I felt it was cleaner to seperate
duplicate address data into a single table and have tables reference it as
necessary -- but can this be done across HABTM and has_one relationships?
Any advice/suggestions would be appriciated.
Thanks
Adam
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails