Hello,
I’m currently trying to populate my database with fixtures and having a
problem.
The table USER has many GROUPS he belongs to and vice versa so it’s m:n
relationship.
Model:
class User < ActiveRecord::Base
has_many :user_groups, :dependent => :nullify
has_many :groups, :through => :user_groups
end
class Group < ActiveRecord::Base
has_many :user_groups, :dependent => :nullify
has_many :users, :through => :user_groups
end
class UserGroups < ActiveRecord::Base
belongs_to :user
belongs_to :group
end
Fixuture of UserGroups:
one:
user: one
group: one
two:
user: two
group: two
And that’s the error I get:
rake aborted!
Mysql::Error: #42S22Unknown column ‘user’ in ‘field list’: INSERT INTO
user_groups
(user
, group
) VALUES (‘two’, ‘two’)
Anyone any idea how to solve it? Thanks!