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 C. 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,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On 15 December 2010 17:49, Dave C. [email protected] wrote:

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.

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 L. wrote in post #968709:

On 15 December 2010 17:49, Dave C. [email protected] wrote:

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.

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

Thanks for your helpful reply.

Dave