Report strategy

I need to offer custom reports but haven’t been able to find an
existing package to help us.

How have other people solved this problem? I read old posts but
haven’t found anything (Ruports isn’t 1.9-compatible, which would bite
us later, and enterprisey tools aren’t an option).

The queries are complicated, so I’ve added the lengthy SQL as heredocs
to models as private methods, and am using find_by_sql in public
methods in my Report class (living in app/models). However if I base
my model off ActiveRecord, I get “table doesn’t exist” errors. I don’t
need a reports table, so I’m doing without and calling find_by_sql
using one of the other model classes.

There’s a ReportsController which calls the Report model class
methods.

It seems like I’m swimming against the current. What’s the Rails-y way
to solve this problem? What I’m doing doesn’t seem right.

The other problem I have is find_by_sql is only returning a couple of
columns from one table, when it’s supposed to return many columns from
several tables.

I can’t convert the query to AR because it consists of subqueries
within subqueries.

I gave up on find_by_sql (it wasn’t adding the attributes it seemed it
should) and am using select_all:

@posts = ActiveRecord::Base.connection.select_all(query_method)