I have two tables which are following
contacts table
id
email
name
company
phone
and
signups table
id
contact_id
code
details
And I have two models contacts and signups and have same controllers as well.
What I want here is to get all data from contacts table where contacts table id = signups table contact_id.
How can I do this in ruby on rails?
Update
Here are my models which are empty for now
class Usercontacts < ActiveRecord::Base
#has_one :signups
#has_one :receiver, :class_name => "Signups"
end
HEre is second model
class Signups < ActiveRecord::Base
attr_accessible :contact_id, :code, :event_id, :details
#belongs_to :usercontacts
#belongs_to :receiver, :class_name => "Usercontacts"
end
Now I am doing something like this my signups controller
class SignupsController < 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
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.