title: How can I show nested json form result where the nested one is from another model/table in rails
body: <p>why Rails does not show the joined table when I use the join method?
  this is my code on my controller:</p>
  <pre class="lang-rb prettyprint-override"><code> def index
     @users = User.joins(:name).all
     render json: @users
   end
  </code></pre>
  <p>the nested name table doesn't show on users table, even if <code>name</code> have foreign_key <code>user_id</code>
  this is the name result</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;id&quot;: 1,
    &quot;title&quot;: &quot;miss&quot;,
    &quot;user_id&quot;: 1,
    &quot;created_at&quot;: &quot;2022-04-15T15:02:28.948Z&quot;,
    &quot;updated_at&quot;: &quot;2022-04-15T15:02:28.948Z&quot;,
    &quot;first&quot;: &quot;mya&quot;,
    &quot;last&quot;: &quot;richard&quot;
  }
  </code></pre>
  <p>this is my name class model</p>
  <pre class="lang-rb prettyprint-override"><code>class Name &lt; ApplicationRecord
    belongs_to :user
  end
  </code></pre>
  <p>this is the user class model</p>
  <pre class="lang-rb prettyprint-override"><code>class User &lt; ApplicationRecord
    ...
    has_one :name, dependent: :nullify.
    ...
    accepts_nested_attributes_for :name
  end
  </code></pre>
  <p>and this is the SQL code generated when I run the code</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT &quot;users&quot;.* FROM &quot;users&quot; INNER JOIN &quot;names&quot; ON &quot;names&quot;.&quot;user_id&quot; = &quot;users&quot;.&quot;id&quot;
  </code></pre>
  <p>I really don't Understand why it doesn't work</p>