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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5 Nov 2008, at 15:03, Heinz Strunk wrote:> > 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'') >IIRC with the foxy fixtures stuff you don''t need user_groups.yml at all your users.yml can contain stuff like bob: groups: one, two Fred> Anyone any idea how to solve it? Thanks! > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Well, doesn''t seem to work: rake aborted! Mysql::Error: #42S22Unknown column ''groups'' in ''field list'': INSERT INTO `users` (`name`, `groups`) VALUES (''test'', ''one'') Fixture of Users: one: name: test groups: one -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5 Nov 2008, at 16:17, Heinz Strunk wrote:> > Well, doesn''t seem to work:just as a sanity check, what version of rails are you using ? Fred> > > rake aborted! > Mysql::Error: #42S22Unknown column ''groups'' in ''field list'': INSERT > INTO > `users` (`name`, `groups`) VALUES (''test'', ''one'') > > Fixture of Users: > one: > name: test > groups: one > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
rails -v Rails 2.1.0 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Spelling error in the model.rb. All good, thanks a lot! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---