Forum: Ruby on Rails merging models/views with scaffolding

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
31ae911dd0fe0ee0b81519d6d2627886?d=identicon&s=25 Gravy Face (gravyface)
on 2006-03-24 21:01
(Received via mailing list)
Allo,

Just started playing around with RoR/scaffolding and have been
impressed so far.  However, it seems to create a 1:1 relationship
between Controllers and Models and the basic CRUD actions -- I need to
CRUD two models from the same views and actions.

I have:

Book model
Book controller, with create/edit/show/destroy/list actions and the
scaffold-gen'ed views.
Category model
Category controller, with create/edit/show/destroy/list actions and
the scaffold-gen'ed views.

I'd like to have:

Book model
Admin Controller, with create/edit/show/destroy/list actions for both
models
Category model

I want to essentially combine the Controllers and views into one so
that when you create/edit/show/destroy a Category you can also create
the Books from the same views/actions.

I've added the appropriate belongs_to and has_many relationships to
each model (and the table pk/fks are in place):

Book
belongs_to: category

Category
has_many: books

Thanks
This topic is locked and can not be replied to.