ActionController::DoubleRenderError

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.

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

Fred

Frederick Cheung 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.

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