Collect

Hi
I have to collect mail addresses like below

Contact.find_by_id(problem.reported_by_id).contact_email_addresses.find(:all,
:conditions => [‘contact_email_address_type_id=?’,2])

Executing above what i am getting is two objects of class
ContactEmailAddress and in that an email field is there. For example
[email protected] and [email protected]
So how can I collect this to an array ? I tried like

EmailArray <<
Contact.find_by_id(problem.reported_by_id).contact_email_addresses.find(:all,
:conditions => [‘contact_email_address_type_id=?’,2]).collect { |mail|
mail.email}

  But is not working.Could you please tell me how I can achieve

this?The above is clearly problem.reported_by_id (ie MailIds of
ReportedBy person) My code continues like

Contact.find_by_id(problem.analyst_id).contact_email_addresses.find(:all,
:conditions => [‘contact_email_address_type_id=?’,2])
Please note analyst_id above…I have to do the same thing to this
also ie to collect mails of Analyst also like above to the same
EmailArray…Like that

Thanks in advance
Sijo

Hi
Here I tried like
email_array = Contact.get_email_ids_of_contacts(problem.reported_by_id)
unless problem.reported_by_id.empty?
It worked and I got the two mailIDs But when I add the next line
like
email_array = email_array +
Contact.get_email_ids_of_contacts(problem.analyst_id) unless
problem.analyst_id.empty?

 Now it is not working What might be the cause.Please help

Note:
In get_email_ids_of_contacts of Contact model just wrote
return
Contact.find_by_id(contact_id).contact_email_addresses.find(:all,
:conditions => [‘contact_email_address_type_id=?’,2]).collect { |mail|
mail.email}

Sijo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs