Combining partials

Hi,

I have 3 controller/model's (Books, Chapters, Sections) and would like
to combine the views into one (list of the books, chapters, sections).
Is this possible? Would I be able to use partials even if they have
different controllers, or do I have to combine all into a single
controller? Any help, tips, advice is appreciated. I am still a
beginner.

DC

Dave Castellano wrote in post #968637:

Hi,

I have 3 controller/model's (Books, Chapters, Sections)

What's a controller/model? Controllers and models are separate things,
and need not come in pairs.

and would like
to combine the views into one (list of the books, chapters, sections).
Is this possible?

Depends on the nature of the views.

Would I be able to use partials even if they have
different controllers, or do I have to combine all into a single
controller?

You can use partials from anywhere. app/views/shared is the usual place
to put partials that are used with multiple controllers.

Any help, tips, advice is appreciated. I am still a
beginner.

DC

Best,

Just assemble the data you need for the partials in whatever
controller you deem appropriate, and in the view render the
appropriate partials passing them the data they need. Don't forget
that if you have a book object @book then its chapters will be
@book.chapters and for each chapter the sections will be
chapter.sections (assuming you have set the associations up
appropriately, and assuming I am interpreting your problem correctly.

Colin

Colin Law wrote in post #968709: