# ActionController::DoubleRenderError

**URL:** <https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091>\
**Category:** Rails\
**Created:** [May 24, 2010, 12:36pm UTC](https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091 "2010-05-24T12:36:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@drk](https://www.ruby-forum.com/u/drk)\
**Post date:** [May 24, 2010, 12:36pm UTC](https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091/1 "2010-05-24T12:36:07Z")

</div>

def dispfriends  
@myfriend=[]  
@myfriendlogin = []

i=0  
@currentgroup = Group.find\_by\_id(params[:groupid])

puts @currentgroup.id

@currentfriends=  
GroupFriend.find\_all\_by\_user\_id\_and\_group\_id(current\_user.id,  
@currentgroup.id)

for n in @currentfriends  
@myfriend=n.friend\_id  
@myusers = User.find\_by\_id(@myfriend)  
@myfriendlogin[i]=@myusers.login  
puts @myfriendlogin[i]  
i=i+1

respond\_to do |format|  
format.html { render :partial =\> ‘users/dispfriends’, :locals =\>  
{:user =\> @myusers}}  
end

end

end

Error:  
ActionController::DoubleRenderError in UsersController#dispfriends

Can only render or redirect once per action

But, I need to display all the values in @myusers.  
How can I pass the values?

Please help.

Thank you.

---

<div class="post-metadata">

**Author:** ![drk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@drk](https://www.ruby-forum.com/u/drk)\
**Post date:** [May 24, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091/2 "2010-05-24T15:56:30Z")

</div>

On May 24, 11:36 am, Ravi D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But, I need to display all the values in @myusers.  
> How can I pass the values?

if you pass the :collection option render will render the partial once  
for each item in the collection

Fred

---

<div class="post-metadata">

**Author:** ![drk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@drk](https://www.ruby-forum.com/u/drk)\
**Post date:** [May 25, 2010, 7:34am UTC](https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091/3 "2010-05-25T07:34:47Z")

</div>

Frederick C. wrote:

> On May 24, 11:36ï¿½am, Ravi D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > But, I need to display all the values in @myusers.  
> > How can I pass the values?
> 
> if you pass the :collection option render will render the partial once  
> for each item in the collection
> 
> Fred

Thanks Fred for your reply.

I modified with the following , but i get only the last value.

def dispfriends  
@myfriend=[]  
@myfriendlogin = []

i=0  
@currentgroup = Group.find\_by\_id(params[:groupid])

puts @currentgroup.id

@currentfriends=  
GroupFriend.find\_all\_by\_user\_id\_and\_group\_id(current\_user.id,  
@currentgroup.id)

for n in @currentfriends  
@myfriend=n.friend\_id  
@myusers = User.find\_by\_id(@myfriend)  
@myfriendlogin[i]=@myusers.login  
puts @myfriendlogin[i]  
i=i+1  
end

respond\_to do |format|

# format.html { render :partial =\> ‘users/dispfriends’, :locals =\>

{:user =\> @myusers}}

format.html { render :partial =\> ‘users/dispfriends’, :collections =\>  
@myusers}

end

end

Im very new to rails please help me in modifying my controller.

Thank you.

---

<div class="post-metadata">

**Author:** ![drk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@drk](https://www.ruby-forum.com/u/drk)\
**Post date:** [May 25, 2010, 8:35am UTC](https://www.ruby-forum.com/t/actioncontroller-doublerendererror/189091/4 "2010-05-25T08:35:13Z")

</div>

On May 25, 6:34 am, Ravi D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks Fred for your reply.
> 
> I modified with the following , but i get only the last value.

I’m not entirely sure what you’re trying to do but the option is  
spelled :collection not :collections and the @myusers object you  
passed is a single object rather than an array,

Fred
