Reputation: 4622
Okay.. I've been banging my head against the wall on this one for a while now.
I have two models, let's say Downloads
and Rankings
, both with their very own unique schema. I need to merge these records by the hour they were created at, and then send that data to my view to display in a table, which looks as follows.
Hour download_count overall_ranking 1:00 10 115 2:00 11 116 ...
I'd like to create a sort of "meta" container, which has all of the attributes from the @download and the @ranking and the hour:
How do I create this meta container object?
I'm able to group by downloads and rankings by hour created, and merge them via a hash. So I have an object that looks like:
@metrics = {"Sun, 06 May 2012 00:00:00" => [<Ranking ...>, <Download ...>], ...}
But I'm not sure how to make a new object that fits my schema above.. My only solution is to create a new class and manually set each attribute I want to transfer over. This feels really cumbersome though.
(I'm using rails 3.0.10 and ruby 1.8.7)
Upvotes: 2
Views: 333