Ravi Dtv wrote:> Hii
> How can i pass array of values from the controller to partial.
>
>
Just like you''d pass any other variable to any other view. No
difference.
> def dispfriends
> @myfriend=[]
> @myfriendlogin = []
> @myusers=[]
This is terrible controller code. To start with, the name of the method
is bad.
>
> 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)
No! Use associations for this.
>
> for n in @currentfriends
> @myfriend=n.friend_id
> puts @myfriend
> @myusers = User.find_by_id(@myfriend)
> @myfriendlogin[i]=@myusers.id
> puts @myfriendlogin[i]
> i=i+1
That''s not how you do it in Ruby. Learn about Array methods such as
each and collect.
>
> end
>
>
>
> I can print @myfriendlogin (id, name, address) individually and show the
> value in the view. But,
>
> My requirement is I need to pass complete @myusers array to my view.
>
> Please help like how can i pass all the fields in @myusers.
It''s just a variable. Pass it like any other variable.
>
> Please help. thank you.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.