Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I could get this line to return the complete nested XML</p> <pre><code>format.xml { render :xml =&gt; @post.to_xml(:include =&gt; [ :links, :assets])} </code></pre> <p>like</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;post&gt; &lt;body&gt;testing.../body&gt; &lt;created-at type="datetime"&gt;2010-09-21T06:19:13Z&lt;/created-at&gt; &lt;id type="integer"&gt;1&lt;/id&gt; &lt;title&gt;1&lt;/title&gt; &lt;updated-at type="datetime"&gt;2010-09-21T06:19:13Z&lt;/updated-at&gt; &lt;links type="array"/&gt; &lt;assets type="array"&gt; &lt;asset&gt; &lt;attachable-id type="integer"&gt;1&lt;/attachable-id&gt; &lt;attachable-type&gt;Post&lt;/attachable-type&gt; &lt;created-at type="datetime"&gt;2010-09-21T06:19:13Z&lt;/created-at&gt; &lt;data-content-type&gt;image/jpeg&lt;/data-content-type&gt; &lt;data-file-name&gt;IMG00017-20100906-1226.jpg&lt;/data-file-name&gt; &lt;data-file-size type="integer"&gt;0&lt;/data-file-size&gt; &lt;id type="integer"&gt;1&lt;/id&gt; &lt;updated-at type="datetime"&gt;2010-09-21T06:19:13Z&lt;/updated-at&gt; &lt;/asset&gt; &lt;/assets&gt; &lt;/post&gt; </code></pre> <p>Here is our model</p> <pre><code>class Post &lt; ActiveRecord::Base has_many :assets, :as =&gt; :attachable, :dependent =&gt; :destroy has_many :links, :as =&gt; :linkable, :dependent =&gt; :destroy ... </code></pre> <p>Link Model</p> <pre><code>class Link &lt; ActiveRecord::Base belongs_to :linkable, :polymorphic =&gt; true ... </code></pre> <p>Asset Model</p> <pre><code>class Asset &lt; ActiveRecord::Base belongs_to :attachable, :polymorphic =&gt; true ... </code></pre> <p>In here, assets and links are not bound to any particular model. In the current usage, they are used in Post. Later on other models can use them.</p> <p>is that what you are trying to achieve?</p>
    singulars
    1. This table or related slice is empty.
    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. 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