I have models Productor, Company and User
I want that a productor AND a company have both an user. An user that belongs to a Company belongs only to this company. An user that belongs to a Productor belongs only to this productor.
so the tables I want to be this way
productor company user
--------- -------- ------
id id id
name name email
user_id user_id password
I tried to do this with has_one association but I got this error
no such column: users.produtor_id: SELECT "users".* FROM "users" WHERE "users"."produtor_id" = 1 LIMIT 1
and my model follows
class Produtor < ActiveRecord::Base
attr_accessible :borndate, :cpf_cnpj, :is_company, :name, :rg
has_one :user
...
class User < ActiveRecord::Base
attr_accessible :email, :password
...
end