title: How to get data from two database tables in ruby on rails
body: <p>I have two tables which are following</p>
  
  <pre><code>contacts table
  id
  email
  name
  company
  phone
  </code></pre>
  
  <p>and </p>
  
  <pre><code>signups table
  id
  contact_id
  code
  details
  </code></pre>
  
  <p>And I have two models <code>contacts</code> and <code>signups</code> and have same controllers as well.</p>
  
  <p>What I want here is to get all data from contacts table where contacts table id = signups table contact_id.</p>
  
  <p>How can I do this in ruby on rails?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here are my models which are empty for now</p>
  
  <pre><code>class Usercontacts &lt; ActiveRecord::Base
  #has_one :signups
  #has_one :receiver, :class_name =&gt; "Signups"
  end
  </code></pre>
  
  <p>HEre is second model</p>
  
  <pre><code>class Signups &lt; ActiveRecord::Base
   attr_accessible :contact_id, :code, :event_id, :details
  
   #belongs_to :usercontacts
   #belongs_to :receiver, :class_name =&gt; "Usercontacts"
  end
  </code></pre>
  
  <p><strong>Now I am doing something like this my signups controller</strong></p>
  
  <pre><code>class SignupsController &lt; ApplicationController
  layout 'admin_layout'
  
  def signups
      #@signups = Contact.joins('LEFT OUTER JOIN signups ON contacts.id = signups.contact_id')
              @contacts = Contact.joins(:sign)
  end
  end
  </code></pre>
  
  <p>but this gets all the data from contacts table. but I want to get only that data which is whose id is present in signups table.</p>