saulabs/reportable

Support parameters on generated methods

Opened this issue · 0 comments

EDIT: Actually, what I propose below is already possible but is not mentioned in the documentation! It seems like any of the options that can be defined when the report is declared with 'reportable' can be included in a hash at runtime.

Let's say I have a User model that has_many Posts and I would like to report on the Posts belonging to the current user (e.g. show the user how many posts they have submitted each day this month). This does not appear to be possible in the current version of reportable.

I can't add a condition based on current_user because it is evaluated when the class is loaded, e.g. the following does not work:

reportable :my, :conditions => ["user_id LIKE ?", current_user]

I would need to be able to specify conditions when the query is run, e.g.:

Posts.my_report(:conditions => ["user_id LIKE ?", current_user]).