2009-01-20

Look how smart I am!

Update: Original problem was solved with hirb. Good job Gabriel!

Recently I was analysing data on production server. Problem domain I worked with is quite complex and consists of several different models. Rails provides great tools to easily cherry-pick interesting data using named_scope, conditions, includes, through. I ended up with a list of records I wanted to inspect.

I worked using console, through screen. List was too long to use 'pp', scrolling with screen is also not too great. What I needed was a simple table with a few columns (and not full list of model's properties). Something among the lines of:


+----+----------------+-------+-------------+
| id | job_posting_id | state | published_at|
+----+----------------+-------+-------------+
| 1  | 20             | del   | 2008-01-01  |
| 2  | 23             | del   | 2008-01-01  |
| ...| 24             | act   | 2008-01-01  |
+----+----------------+-------+-------------+

Recently I have noticed Ruport which at glance looked like a perfect tool for a job. But it wasn't.

After a few hours of skimming through examples, documentation, and even a book (now free as in beer! - recon that) I failed to find a single concise example of how can I achieve my goal.

Rather, Ruport authors assume that you will be willing to use their CSV loading code, or maybe their acts_as_reportable plugin and surely rewrite half of your application, including record selecting logic, possibly ignoring any goodies Rails provides in this area.

Now do not get me wrong. I'm not saying that Ruport is a bad software. I actually have no idea if it's good or bad. But it does not provide quick solution for the simplest case possible.

Both documentation and API focus on how great Ruport is and how great it manages your reports. It fails to show how Ruport can easily aid you in your daily tasks.

It's a perfect example of Ruport's authors 'Look how smart I am' approach. Personally I prefer to use software which is written in 'Look how easy it is' manner.

Update: While looking for solution to my problem I encountered official ruport discussion group. To post there you need to apply for membership, which I did. After two days my admission was rejected... Good job in helping your users, guys!

1 comments:

Michael Cowden said...

Check out the rdoc on acts_as_reportable

Directly from their docs:
Book.report_table(:all, :only => ['title'])

That gets just the title field... you can do :except too.

Pretty sure that handles what you need.

There's also an entire book on Ruport:
http://www.lulu.com/product/file-download/ruport-book/2660918

And it's free.