Actionmailer Help Needed

Jenny Blunt
Thu, 28 Jul 2011 16:05:01 -0000

Hello everyone,

Nice to meet you all, am new to the forum.

I''m stuck with rake / actionmailer trying to display a set of found
records.

We have a simple actionmailer rake task that is supposed to send a daily
email digest of tasks that are due for a specific user. So far, it''s
working but the email only displays the first message.

In my task model

scope :tasksdue, lambda {
       where("dueddate > ? AND status = ?", Date.today, false)
  }

 def self.send_reminders
      Task.tasksdue.find_each do |task|
      TaskMailer.deliver_task_due task
 end
task_mailer.rb

class TaskMailer < ActionMailer::Base
  def task_due(task)
      recipients @task.user.email
      from       "email-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org"
      subject    "Your report entitled"
      sent_on    Time.now
      content_type "text/html"
      body       :task => task
  end
end

In my rake tasks file I have

namespace :cron do
  desc "Send email reminders to all users"
  task :send_reminders => :environment do
    Task.send_reminders
  end
end

And in my view, task_due.html.erb, I''ve tried this.




    <meta content="text/html; charset=UTF-8"
http-equiv="Content-Type"
/>


Ahoy! <%= @task.responsible %>
    <% Task.send_reminders.each do |report| %>
      <%= Task.send_reminders.title %>
    <% end %>


This results in a loop, stack level too deep. I think I understand why.
Can you help me understand how I display all my records from the found
set?

All the best

Jenny Bx