# Trying to create a collection to use for a report

**URL:** <https://www.ruby-forum.com/t/trying-to-create-a-collection-to-use-for-a-report/194457>\
**Category:** Rails\
**Created:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/trying-to-create-a-collection-to-use-for-a-report/194457 "2010-09-06T16:39:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/trying-to-create-a-collection-to-use-for-a-report/194457/1 "2010-09-06T16:39:33Z")

</div>

I have a database of people that have used a local foodbank. The  
problem I’m having now is that i need a way to put 2 collections into  
one variable, like rails does it for partials. I want a variable  
@oxford that does a Household.find\_all\_by\_zip(‘01540’). This is no  
problem.

The trouble comes when I try to combine lists of new families and  
returning families to feed the partials properly… What I have is a  
main page

monthly.erb  
oxford families  
render partial =\> ‘monthly\_report’, :collection =\> @oxford

\_monthly\_report.erb  
new families  
render partial =\> 'monthly\_graph, :collection =\> monthly\_report.new

returning families  
render partial =\> 'monthly\_graph, :collection =\>  
monthly\_report.returning

Rails doesn’t seem to like these two areas in the monthly\_report  
variable without being setup, so I hope there is a way to do this. I’m  
hoping there is a way to set your collections the way you want to do a  
report. Please help me with the proper way to set this variable up

Bob [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/trying-to-create-a-collection-to-use-for-a-report/194457/2 "2010-09-06T16:39:39Z")

</div>

On Sep 4, 9:18 am, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a database of people that have used a local foodbank. The  
> problem I’m having now is that i need a way to put 2 collections into  
> one variable, like rails does it for partials. I want a variable  
> @oxford that does a Household.find\_all\_by\_zip(‘01540’). This is no  
> problem.
> 
> The trouble comes when I try to combine lists of new families and  
> returning families to feed the partials properly… What I have is a  
> main page
> 
> monthly.erb  
> oxford families  
> render partial =\> ‘monthly\_report’, :collection =\> @oxford
> 
> \_monthly\_report.erb  
> new families  
> render partial =\> 'monthly\_graph, :collection =\> monthly\_report.new
> 
> returning families  
> render partial =\> 'monthly\_graph, :collection =\>  
> monthly\_report.returning
> 
> Rails doesn’t seem to like these two areas in the monthly\_report  
> variable without being setup, so I hope there is a way to do this. I’m  
> hoping there is a way to set your collections the way you want to do a  
> report. Please help me with the proper way to set this variable up

What do you mean by “doesn’t seem to like”? What do the new &  
returning methods return ?

Fred
