Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Whether it is best practice or not is a highly debatable topic. For instance, you have to mind the object size limit (currently 4 MB, but will go up soon).</p> <p>as for your question: I suggest that you change </p> <pre><code> embeds_many :replies, :class_name =&gt; 'Message' embedded_in :message, :inverse_of =&gt; :replies </code></pre> <p>to </p> <pre><code> embeds_many :replies, :class_name =&gt; 'Message' referenced_in :message </code></pre> <p>And you will also have to specify both connections manually (that should not be a problem, as they are probably immutable anyway).</p> <pre><code>irb(main):002:0&gt; msg1 = Message.new :subject =&gt; 'new question' =&gt; #&lt;Message _id: 4cc7699f457601d7e8000001, created_at: nil, body: nil, updated_at: nil, subject: "new question", read_at: nil, sender_deleted: false, message_id: nil, recipient_deleted: false&gt; irb(main):003:0&gt; msg2 = Message.new :subject =&gt; 'first comment' =&gt; #&lt;Message _id: 4cc769b6457601d7e8000002, created_at: nil, body: nil, updated_at: nil, subject: "first comment", read_at: nil, sender_deleted: false, message_id: nil, recipient_deleted: false&gt; irb(main):005:0&gt; msg2.message = msg1 =&gt; #&lt;Message _id: 4cc7699f457601d7e8000001, created_at: nil, body: nil, updated_at: nil, subject: "new question", read_at: nil, sender_deleted: false, message_id: nil, recipient_deleted: false&gt; irb(main):007:0&gt; msg1.replies &lt;&lt; msg2 =&gt; [#&lt;Message _id: 4cc769b6457601d7e8000002, created_at: nil, body: nil, updated_at: nil, subject: "first comment", read_at: nil, sender_deleted: false, message_id: BSON::ObjectId('4cc7699f457601d7e8000001'), recipient_deleted: false&gt;] irb(main):008:0&gt; msg1.save =&gt; true </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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