I have a companies table and a leads table. I am pulling a bunch of leads and need to combine each lead with 2 ID columns from the companies table. I want to keep the companies table as the single source of truth for these ID's (and hence not adding these columns to the leads table where it could get out of sync).
Right now I pull all the leads and loop through everyone to add this data. I am assuming there's a more efficient way to do this but I'm not sure how. Can someone help?
sql ruby-on-rails ruby-on-rails-4 activerecord