saulabs/reportable — Issue #15: Support parameters or chaining on generated methods
Author: mtjhax
Created: 2012-02-11 02:20:53+00:00
State: open

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. :conditions => ["user_id LIKE ?", current_user] won't work).

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]). Chaining would be even cooler, e.g. Post.my_report.where(:user_id => current_user.id).