Dave Birch
2010-Jan-16 01:53 UTC
Parsing a string from a database and executing the result
Hi, 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 <code>@results.size</code> and they spent <code>@results.collect(&:spend).sum</code> on your product this year". My original design is in this post: http://www.ruby-forum.com/topic/202016#880654 Any better suggestions would be very much welcome. Thanks in advance Dave -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.