On 10 Sep 2008, at 07:24, Sijo Kg wrote:

>
> Hi
>   I am trying to collect name and email of a person to an array (Or
> hash?) like
> [[name1,emailid],[name2,emailid].......] But I dont know how to do  
> that.
> I tried like
>
> email_array =
> Contact.get_email_id_and_name_of_contacts(problem.reported_by_id)  
> unless
> problem.reported_by_id.blank?
>
> And in Contact class
>
> def self.get_email_ids_of_contacts(contact_id)
>  return  Contact.find_by_id(contact_id).name,
> Contact.find_by_id(contact_id).contact_email_addresses.find(:all,
> :conditions => ['contact_email_address_type_id=?',2]).collect { |mail|
> mail.email}
> end
>

Collect just bungs whatever your block evaluates to in an array. If  
that block evaluates to an array then you'll get an array of arrays  
back.

Fred
>      Here I tried to return two value at a time .But not suceeded .How
> can I do that?Please help
>
> Sijo
> -- 
> 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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to