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 protected]"
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.
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"
/>
</head>
<body>
<h1>Ahoy! <%= @task.responsible %></h1>
<% Task.send_reminders.each do |report| %>
<%= Task.send_reminders.title %>
<% end %>
</body>
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
--
Posted via http://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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.