# Trying to do a user list and getting double render errors

**URL:** <https://www.ruby-forum.com/t/trying-to-do-a-user-list-and-getting-double-render-errors/229181>\
**Category:** Rails\
**Created:** [July 29, 2010, 6:46am UTC](https://www.ruby-forum.com/t/trying-to-do-a-user-list-and-getting-double-render-errors/229181 "2010-07-29T06:46:32Z")\
**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:** [July 29, 2010, 6:46am UTC](https://www.ruby-forum.com/t/trying-to-do-a-user-list-and-getting-double-render-errors/229181/1 "2010-07-29T06:46:32Z")

</div>

Here is where I am now. A render :partial at the \*\*\*\* would solve my  
problem, but another render doesn’t seem to be allowed. Render\_pdf  
uses the only one allowed. Is there another way to do this?  
At the moment, it works fine, but only gives me 1 user, even though it  
makes the collections for each user.

```
                         Controller

```

def print  
@households = Household.find(:all, :order =\> “last\_name,  
first\_name”)  
@households.each { |@household|  
@today = Date.today  
@year = @today.year  
@churches = Church.find(:all, :order =\> “name”).map {|u|  
[u.name, u.id]}  
@thisyear =  
Visit.find\_all\_by\_year\_and\_household\_id(Date.today.year,  
@household.id)  
@lastyear =  
Visit.find\_all\_by\_year\_and\_household\_id(Date.today.year-1,  
@household.id)  
@yearbefore =  
Visit.find\_all\_by\_year\_and\_household\_id(Date.today.year-2,  
@household.id)

* * *

}  
date=`date +%Y%m%d-%H:%M`  
respond\_to do |format|  
format.pdf { send\_data render\_to\_pdf( :action =\> ‘print’,  
:layout =\> ‘pdf\_report’),  
:filename =\>  
“Household\_List\_for\_” + date }  
end  
end

```
                   First view

```

\<% javascript\_include\_tag :defaults %\>

debugger  
\<% get\_totals(@household) %\>

```
### Food Shelf
<% form_for @household, :url => household_path(@household), :html =>
{ :method => 'put' } do |household| %>
```

| \<%= @child %\>debugger

| Family Size | \<%= @family%\> | 0-4 Years | \<%= @under5 %\> | 5-17 Years | 18-64 Years | \<%= @adult %\> | 65 & Over | | \<%= @senior %\> |
| \<%= render :partial =\> 'household', :object =\> @household %\> | \<%= render :partial =\> 'people', :object =\> @household %\> |
|
| |

#### Visits to Foodshelf

\<% end %\>

|
| |
| **Month of \<%= Date.today.year %\>** \<%= render :partial =\> 'visit', :object =\> @thisyear %\>

| Monthly | | **Bread & Veg only for Week** |
| --- | --- | --- |
| 1 | 2 | 3 | 4 | 5 |
| --- | --- | --- | --- | --- |

 | **Month of \<%= Date.today.year-1 %\>** \<%= render :partial =\> 'visit', :object =\> @lastyear %\>

| Monthly | | **Bread & Veg only for Week** |
| --- | --- | --- |
| 1 | 2 | 3 | 4 | 5 |
| --- | --- | --- | --- | --- |

 | **Month of \<%= Date.today.year-2 %\>** \<%= render :partial =\> 'visit', :object =\> @yearbefore %\>

| Monthly | | **Bread & Veg only for Week** |
| --- | --- | --- |
| 1 | 2 | 3 | 4 | 5 |
| --- | --- | --- | --- | --- |

 |

 |

---

<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:** [August 2, 2010, 9:55pm UTC](https://www.ruby-forum.com/t/trying-to-do-a-user-list-and-getting-double-render-errors/229181/2 "2010-08-02T21:55:34Z")

</div>

Finally found a way around this. Only 1 render is allowed at the  
controller level, but a view can have as many as wanted, so…  
Leave the only allowed render in the controller for render\_pdf, and do  
a find(:all) in the controller. In the view with the same name as the  
controller action, do a \<%= render :partial =\> ‘whatever’, :object =\>  
@variable\_from\_controller %\>

next make a partial view called \_whatever.html.erb or \_whatever.erb  
for pdf output. The variable holding one record from the list will be  
called whatever, with no @ before it. This partial is where whatever  
output is wanted per record should be done.

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