Topic: Complex views in a RESTful world

I am struggling to find a good, clean way of building complex views in my app without polluting my controllers.

My specific problem is a "Dashboard" style view that collects information from a range of models and views ... at the moment I am playing with an interface that loads content from individual controllers via Ajax and populates the page.

eg: a div is populated with User list by a caller to the User controller and List action. The Dashboard just contains some divs and code to load content

Is there a better way of handling this type of thing?

Toby Hede
===================================================
FiniteStateMachine - Software Development for Social Networks
===================================================

Re: Complex views in a RESTful world

Are you just using AJAX so you don't have to duplicate the user list in the dashboard controller? You shouldn't ever use AJAX for cleaning up the design. Instead use partials.

The dashboard type interface usually doesn't fit well in the RESTful design. Instead just create a non-RESTful controller to handle it.

Railscasts - Free Ruby on Rails Screencasts

Re: Complex views in a RESTful world

If I use partials I have to replicate the logic though. The User controller already has the code for returning a list of users, i would need to replicate that in the Dashboard to enable a partial to work.

Most of my views are like this, really. If you look at something like Basecamp it does the same thing a single view may have several different bits of data.   

I guess in a REST world you tend toward a one function per page type of interface?

Toby Hede
===================================================
FiniteStateMachine - Software Development for Social Networks
===================================================

Re: Complex views in a RESTful world

You can either move the logic into the model or a helper method.

Railscasts - Free Ruby on Rails Screencasts

Re: Complex views in a RESTful world

I just had a head-slap moment. Of course!

Logic in the controller can be moved ...

Um, yeah.

Toby Hede
===================================================
FiniteStateMachine - Software Development for Social Networks
===================================================