Rails relationship's advice
I need to model the following relationships and would like some advice on how to properly model it.
There is a user, house, apartment, garden, furniture
So a user can either have a house or an 开发者_JAVA技巧apartment but not both.
Both house and apartment can have furniture but only the house can have garden.
So the biggest issue is user has_one house | has_one apartment, how can I model this ?
Consider using single table inheritance for this (a little wasteful because of all the null gardens, but depending on the scale of your db, that may not end up being an issue), or possibly a polymorphic relationship (user has_one dwelling).
精彩评论