Using Routing helpers in a Rake task
Posted
by trobrock
on Stack Overflow
See other posts from Stack Overflow
or by trobrock
Published on 2010-05-24T00:00:00Z
Indexed on
2010/06/05
17:12 UTC
Read the original article
Hit count: 259
I have a rake task that sends out the next 'x' invitations to join a beta it uses this code:
desc "This will send out the next batch of invites for the beta"
task :send_invites => :environment do
limit = ENV['limit']
c = 0
invitation = Invitation.all(:conditions => { :sent_at => nil, :sender_id => nil }, :limit => limit).each do |i|
Mailer.deliver_invitation(i, register_url(i.token))
c.increment!
end
puts "Sent #{c} invitations."
end
I need to pass in the 'register_url' to the Mailer in order for the link to show up in the email, but since this is running from a rake task and not from a request it does not have a access to the helper methods. What is the best way of achieving this?
© Stack Overflow or respective owner