I am using dynamic fixtures and whenever I run my tests I am getting an error that thinks my association is a column, when it should be owner_id
:
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'owner' in 'field list': INSERT INTO `companies` (`custom_host`, `name`, `created_at`, `updated_at`, `api_key`, `id`, `subdomain`, `owner`) VALUES ('testerapp.com', 'Some Company', '2009-11-29 21:39:29', '2009-11-29 21:39:29', 'ae2b1fca515949e5d54fb22b8ed95575', 467557389, 'some_company', 'garrett')
In my companies.yml
file I have this:
some_company:
name: Some Company
subdomain: some_company
custom_host: testerapp.com
api_key: <%= "testing".to_md5 %>
owner: garrett
And users.yml
:
garrett:
company: some_company
login: garrett
email: [email protected]
...
locale: en
role_name: owner
Here are my models as well:
class Company < ActiveRecord::Base
has_one :owner, :class_name => "User"
has_many :users
validates_associated :owner
end
class User < ActiveRecord::Base
belongs_to :company
end
Could my problem be because I am associating User
twice within Company
? This is making testing really hard right now, and I was hoping someone could shine some light as to why it isn't reading my associations correctly.
Thanks!