On 2 Dec 2007, at 13:03, yachtman wrote:
>
> Ok, I must be lame. Can''t figure out how to create a new entry in
my
> HABTM models. I just want to add a new book with two authors.. How do
> I do it?
>
> class Author < ActiveRecord::Base
> has_and_belongs_to_many :books
> end
>
> class Books < ActiveRecord::Base
> has_and_belongs_to_many :authors
> end
Your Books model should be called Book.
Once that''s ok it''s as easy as book.authors = [author_1,
author_2]
Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---