Is this while the book is still unsaved (still new) or after it's
saved via edit page?

For the new case, I believe you'll have to tweak the controller to
handle assigning the chapters to the book as there is no id.  For the
second, if nothing else you can replace the book input with a hidden
field that has the book_id.

On Jun 19, 1:00 pm, bcavileer <[email protected]> wrote:
> I've been stuck on a problem with nested models.  I need to set the
> default for the belongs_to
>
> I've created two models, Book and Chapter.  Book has a title:string.
> Chapter has a chapter_name:string.
>
> /app/models/book.rb contains  has_many :chapters, :accessible =>
> true, :dependent => :destroy
> /app/models/chapter.rb contains belongs_to :book
>
> When I create a new book I get these fields:
>
> Book Title: [                   ]
> Chapters:   Chapter Name: [                 ]   [+]
>                   Book: [ ]
>
> I get the <input-many> created automatically to add new Chapters in
> the book.
>
> How can I automatically assign these new Chapters to this Book?
> Can I hide the Book: [ ] field?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to