drk
May 24, 2010, 12:36pm
1
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][email protected]
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.
drk
May 24, 2010, 3:56pm
2
On May 24, 11:36 am, Ravi D. [email protected] 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
drk
May 25, 2010, 7:34am
3
Frederick C. wrote:
On May 24, 11:36�am, Ravi D. [email protected] 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][email protected]
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.
drk
May 25, 2010, 8:35am
4
On May 25, 6:34 am, Ravi D. [email protected] 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