I originally posted this question in the ruby forum thinking that I had
a design that would work and just needed help implementing it. However,
I’ve been advised to try here for an alternative way to solve my
problem…without creating the security hole that my method does.
I’d like to accomplish the following:
I’ve got a “macro” that is generating a bunch of reports. The reports
contain lines like “the number of people in this group are X and they
have spent a total of Y on your product this year”. The problem is, I
can’t substitute X and Y for their real values at the time the macro
runs, because I don’t know what filters the user will apply when viewing
the reports. So I need a way
to do the calculations and substitute in the values when the user views
the report, and to recalculate these each time the user changes the
filter (e.g. show me only people older than 30).
The controller will be pulling together a “@results” variable, but will
not necessarily know what kinds of stats need to be pulled from it.
That’s why i’d like to be able to do things like “the number of people
in this group are
@results.size and they spent
@results.collect(&:spend).sum on your product this year”.
My original design is in this post:
Any better suggestions would be very much welcome.
Thanks in advance