Re: Actionmailer Help Needed

Frederick Cheung
Fri, 29 Jul 2011 10:22:31 -0000

On Jul 29, 10:16 am, Jenny Blunt
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> Hi there Fred
>
> Thanks for your answer.
>
> I''m just getting in a pickle with Actionmailer I have to say :(
>
> Am just trying to send a single email to each user. I need the content
> to list their due tasks.
>
> That''s why I was trying to display the found set.
>

Forgetting about actionmailer for a second, you''re going about things
slightly backwards. send_reminders  is iterating over a set of tasks,
sending an email per task - there''s nothing you can do in your mailer
that is going to get that down to one per user.

Your send_reminders method should first be identifying those users
with at least one due task, then iterate over those users. Then you
mailer template can iterate over that user''s tasks

You might find it helpful to ditch the actionmailer bit for half an
hour and make a view / controller that would display all this
information (eg one action that displays a list of users with due
tasks and then one action that displays the list of tasks for one such
user). If you can get that going then transplanting it to a mailer
situation should be straightforward

Fred



> Thanks, Jx
>
> --
> Posted viahttp://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@googlegroups.com.