Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to show data from two tables in a single view
    primarykey
    data
    text
    <p>I have two tables: one named <code>um_org_data</code> and the other <code>addresses</code>.</p> <p>The problem is that I want to show the data from <code>um_org_data</code> with <code>addresses</code> where <code>addresses</code> has a foreign key <code>um_org_datum_id</code>.</p> <p>Here is the code of my view in which I want to show the data from two tables together:</p> <pre><code>&lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="span3 pull-right"&gt; &lt;div class="well"&gt; &lt;h2&gt;Heading&lt;/h2&gt; &lt;p&gt;Sample text&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="span9"&gt; &lt;h2&gt;Organization Details&lt;/h2&gt; &lt;table class="table table-hover"&gt; &lt;tr&gt; &lt;th col span="1" style="width: 200px"&gt; &lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Organization Name: &lt;/th&gt; &lt;td&gt;&lt;%= @um_org_datum.org_name %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th col span="1" style="width: 250px"&gt; &lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Organization Description: &lt;/th&gt; &lt;td&gt;&lt;%= @um_org_datum.org_description %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th col span="1" style="width: 250px"&gt; &lt;/i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Web Domain: &lt;/th&gt; &lt;td&gt;&lt;%= @um_org_datum.webdomain %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th col span="1" style="width: 200px"&gt; &lt;%= fields_for :address_attributes do |p| %&gt; &lt;%= p.label 'Office Address' %&gt;&lt;br /&gt; &lt;/th&gt; &lt;td&gt;&lt;%= p.address.offc_addr %&gt;&lt;/td&gt; &lt;% end %&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th col span="1" style="width: 200px"&gt; &lt;/i&gt;&amp;nbsp;&amp;nbsp;Office Phone Number: &lt;/th&gt; &lt;td&gt;&lt;%= @um_org_datum.offc_ph %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div class="control-group"&gt; &lt;div class="controls"&gt; &lt;a class="btn" href="/um_org_data" style="text-color:black"&gt;View all&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I don't use any join query in the controller as I don't know how to use join query. If this problem needs a join query, please tell me what is the syntax and what I have to change in the view form to show attributes of both tables.</p> <p>table name: <code>um_org_data</code> , attributes: <code>id, oeg_name, org_description, webdomain</code></p> <p>table name: <code>adrresses</code> , attributes: <code>id, offc_addr, um_org_datum_id</code></p> <p>Thanks in advance!</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