saulabs/reportable — Issue #16: Association and Join support
Author: mtjhax
Created: 2012-02-11 02:31:18+00:00
State: open

Let's say I want to report on Posts, but only where the User who submitted the post has country == "united states"? Given the current query options this is impossible, yet basic filtering on an associated model is something of a necessity in this sort of tool.

I feel like you need to somehow leverage Arel so I can do something like the following:

class Post < ActiveRecord::Base
belongs_to :user
reportable :usa_posts, :joins => :user, :conditions => ["users.country LIKE 'united states'"]

Make sense?

Actually, it would be ideal if instead of generating methods up-front if reportable was chainable with Arel, so for example you could simply say:

Post.joins(:user).where("users.country LIKE 'united states'").reportable(:grouping => :day)

In this case cache support would be one of many tricky issues to navigate.