On Mon, Feb 13, 2012 at 20:43, Felipe Pieretti Umpierre <[email protected]> wrote:
> Hello, I'm trying to insert into my migrate but when I try on rails > console this error shows: ... > 1.9.3-p0 :009 > group << email > NoMethodError: undefined method `<<' for #<Group:0xa7efb80> This is the chunk you need to worry about. It's telling you that you haven't defined any << method for your Group model. AR doesn't provide one, as such a thing just wouldn't make sense for most models. > class Email < ActiveRecord::Base > has_and_belongs_to_many :groups > validate :email > end ... > class Group < ActiveRecord::Base > has_and_belongs_to_many :emails > validate :name > end You may also want to consider using "has_many :through" rather than has_and_belongs_to_many. I've heard horror stories of people having trouble getting HABTM to work right (though I never had problems with it myself), and if you ever decide you want to "decorate" that relationship with any additional data, it can be very difficult to retrofit a HABTM relationship to become HMT. -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

