Blog An exploration of the art and
craft of software development

Latest ActiveWarehouse changes

Posted by Marty Haught on Monday, February 04, 2008

The large render code refactoring has been checked into ActiveWarehouse’s trunk today. It took me a bit longer than I originally thought back around the new year to get all the changes in. However, I do believe it was worth it. I intend to do a new tutorial with the new approach to rendering but that won’t happen for another week or two. Instead I’ll give a short example to get you running.

One of the things that has changed is the way you render a report’s view. To help break the render code up into usable parts we’ve come up with the View model to handle extracting data from the report with the awareness of the html layer and the current state of the report’s view. This will make it much easier to roll out new views such as flex, chart apis, etc.

Let’s take a simple example. You construct a new report as you have always done so:

@report = ActiveWarehouse::Report::TableReport.new(...)

Then you set up your view such as:

@view = @report.view(params)

In the template your render method is new. The old render_report is gone so you’ll need to switch over to the new render method.

<%= render_report_from(@view) %>

render_report_from takes a view object. That is the simple example.

You may be asking why would we bother with these changes. Well, it was vital to allow more flexibility in how we render the reports. For instance, you can choose to have your report do totals at the bottom.

@view = @report.view(params, :with_totals => true)

Again, I’ll go into more details on this in another post. One thing that is almost ready is our YUI sortable table code. You may notice the yui_adapter.rb file in the plugin. Once we do some clean up we’ll be releasing our first version of the YUI4Rails plugin which will allow you then to do sortable reports. More on that later.

blog comments powered by Disqus