Reputation: 5559
I'm trying to use heroku's scheduler and a rake task to send myself a daily report.
In scheduler.rake I have
task :send_report => :environment do
user_count = User.count
share_count = Share.count
ReportMailer.send(user_count, share_count).deliver
end
My ReportMailer looks something like this
class ReportMailer < ActionMailer::Base
def send(user_count, share_count)
@user_count = user_count
@share_count = share_count
mail(from: "[email protected]", to: "[email protected]", subject: "Report")
end
end
And the view send.html.erb I have
<p>Report</p>
<p>Users: <%= @user_count %></p>
<p>Shares: <%= @share_count %></p>
I'm getting an error when I run heroku run rake send_report
Sending report...
(1.6ms) SELECT COUNT(*) FROM "users"
(1.3ms) SELECT COUNT(*) FROM "shares"
rake aborted!
2 is not a symbol
/app/lib/tasks/scheduler.rake:5:in `block in <top (required)>'
Tasks: TOP => send_report
User.count = 2 so I'm assuming I have to pass the 'counts' in a different way?
Upvotes: 2
Views: 773
Reputation: 2167
send
is a method defined by Object
. Rename your mailer action.
Upvotes: 1