:include => :model => :only... excludes columns if one of returned rows doesn't include the :model.column

4 views
Skip to first unread message

gluis

unread,
May 20, 2009, 1:39:14 PM5/20/09
to Ruby Reports
hi,
as the long-subject line suggests:

i'm confused about some behavior w/ the following from
acts_as_reportable:

assume 2 models:
Member :has_many :events, :through => some_other_model
Event, :has_many :members, :through => some_other_model

assume 2 records in members table
assume 1st from members has an event, the other doesn't

this
Member.report_table(:first, :only => [:login], :include => {:events =>
{:only => [:title]}})
returns both login and event.title columns

BUT
this
Member.report_table(:all, :only => [:login], :include => {:events =>
{:only => [:title]}})
returns only the login for Member (b/c the other record in members
doesn't have an event associated)

i can fix it by using a transform, but i'm writing a reporting system
for ppl to compose their own reports (so, they're generated on the
fly), and although i could make it work using transform, it sounds
like a lot of spaghetti code for something i assume ruport handles
already (and i just haven't figured it out).

any suggestions?

thanks a million,

louis

Andrew France

unread,
May 20, 2009, 6:45:16 PM5/20/09
to ruby-r...@googlegroups.com
gluis wrote:
> i'm confused about some behavior w/ the following from
> acts_as_reportable:
>
> assume 2 models:
> Member :has_many :events, :through => some_other_model
> Event, :has_many :members, :through => some_other_model
>
> assume 2 records in members table
> assume 1st from members has an event, the other doesn't
>
> this
> Member.report_table(:first, :only => [:login], :include => {:events =>
> {:only => [:title]}})
> returns both login and event.title columns
>
> BUT
> this
> Member.report_table(:all, :only => [:login], :include => {:events =>
> {:only => [:title]}})
> returns only the login for Member (b/c the other record in members
> doesn't have an event associated)

Could you please try the latest from GitHub at:
http://github.com/ruport/acts_as_reportable/tree/master

Should work as a gem with GitHub as a source (ruport-acts_as_reportable
I guess), vendor'd in Rails, or just requiring the single lib file directly!

Please let me know if this fixes your issue and doesn't break any other
reports you may have. If so, I will aim to get this released into the
proper gem repository next week as the fix has been lingering around for
quite a while now.

All the best,
Andrew


gluis

unread,
May 20, 2009, 10:57:36 PM5/20/09
to Ruby Reports
thanks, andrew, i'll chk test this out tomorrow(may 21) and report
back!

gluis

unread,
May 20, 2009, 11:10:47 PM5/20/09
to Ruby Reports
well, being an impatient sort, i didn't wait till tomorrow. success.

it worked like a charm! nicely done.

thanks! you've saved me from writing a lot of lines of ugly code!
:-)

On May 20, 6:45 pm, Andrew France <andrew+li...@avito.co.uk> wrote:
Reply all
Reply to author
Forward
0 new messages