I have two models, users and companies as indicated below. The users
table has a foreign_key "company_id".
class User < ActiveRecord::Base
class Company < ActiveRecord::Base
In my controller:
@user = User.where(:id => params[:id]).includes(:companies)
I get the following error:
SQlite3::SQLException: no such column: companies.user_id: SELECT
"companies".* FROM "companies" WHERE "companies"."user_id" IN ('8')
Why is RAILS getting the foreign key wrong and why is it trying to
pull columns in the users table into the companies model?