Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with relations
    primarykey
    data
    text
    <p>Hey I have a problem with the extension of the existing dependency models. Well, according to between the models are as follows: I have a User model: </p> <pre><code>class User &lt;ActiveRecord::Base has_many :words, :through =&gt; :memo_words has_many :memo_words, :dependent =&gt; :destroy end class MemoWord belongs_to :user belongs_to :word end class Word has_many :translations, :dependent =&gt; :destroy has_many :memo_words, :dependent =&gt; :destroy end class Translation belongs_to :word end </code></pre> <p>This is a diagram now: <a href="http://img221.imageshack.us/img221/4232/przedik.png" rel="nofollow">http://img221.imageshack.us/img221/4232/przedik.png</a></p> <p>Word model represents a word in one language and the model represents the Translation translation of individual words. I want to resolve the situation when a record in the table and the Word, there is no record Translation (word has no translation). I want to allow for user to add their own translations, but translations done by adding a local (per user). Due to the lack of relationship between Translation and User, the User is not possible to add words. And I question whether a good solution is to add the model UserTranslation: </p> <pre><code>UserTranslation class belongs_to :word belongs_to :user end </code></pre> <p>And diagram with situation after change. <a href="http://img851.imageshack.us/img851/7269/75031527.png" rel="nofollow">http://img851.imageshack.us/img851/7269/75031527.png</a></p> <p>Which would have the same functionality as the model of Translation. In practice, I would have to copy the model to UserTranslation Translation by adding only 'belongs_to :user'. Is there a better approach to the problem</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload