Actionmailer / @recipeints

Hi all,

i’m trying to email multiple people based on certain criteria.

i do a search like

@stacks = Group.find(:all, :conditions => [“component_id = ?”, 2])
this populates stack to contain multiple groups with component_id =2.
How do i populate @recipients to contain all possible @stack.email.

Let me clearify. Each stack has its own email, and i need to include
each stack.email into @recipients.

i’ve been trying to do

@stacks.each do |stack|
@recipients = stack.email
end

But i know this is wrong, but i think it’s a step in the right direction

Please help if possible,
yng

@recipients = Array.new

@stacks.each do |stack|
@recipients << stack.email
end

would do the trick. If you only want to load the email attribute you can
use
a finder that only loads that field as well.

You want to iterate through @stacks, adding the emails to an array:

@recipients = []
@stacks.each {|stack| @recipients << stack.email}

or, more directly:

@recipients = @stacks.map {|stack| stack.email}

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

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