# Derived model associates with a model that base associates with in a different way

**URL:** <https://www.ruby-forum.com/t/derived-model-associates-with-a-model-that-base-associates-with-in-a-different-way/189076>\
**Category:** Rails\
**Created:** [May 24, 2010, 4:18am UTC](https://www.ruby-forum.com/t/derived-model-associates-with-a-model-that-base-associates-with-in-a-different-way/189076 "2010-05-24T04:18:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8c91f0/32.png) [@ali](https://www.ruby-forum.com/u/ali)\
**Post date:** [May 24, 2010, 4:18am UTC](https://www.ruby-forum.com/t/derived-model-associates-with-a-model-that-base-associates-with-in-a-different-way/189076/1 "2010-05-24T04:18:48Z")

</div>

Hello,

So I have an Attribute model with lists the attributes of an object.  
The attributes can be of different types so I have derived classes as  
well, in this case I have a derived SubjectiveAttribute. The problem  
I’m having revolves around my User model. A user is allowed to give  
each attribute a weighting (which tells the system how important an  
attribute is to a user). So, there’s a Weight model and then Attribute  
has the associations has\_many :weights and has\_many :users, :through  
=\> :weights. The problem is that SubjectiveAttribute is related to the  
users in a different way, subjective attributes can be rated as well  
as weighted. So SubjectiveAttribute has the association  
has\_many :ratings and has\_many :users, :through =\> :ratings.

def Attribute  
belongs\_to :attributable, :polymorphic =\> true  
has\_many :weights  
has\_many :users, :through =\> :weights  
def SubjectiveAttribute \< Attribtue  
has\_one :attribute, :as =\> :attributable  
has\_many :ratings  
has\_many :users, :through =\> :ratings

Is this ok or are there problems which could occur that I’m no seeing?  
Are there going to be clashes or confusion when I do something like  
sub\_attribute.users or attribute.users?

Thanks in advance.
