collect

S

Sijo Kg

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
(e-mail address removed) and (e-mail address removed)
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
 
S

Sijo Kg

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top