1
我有發出下一個「X」的邀請參加一個測試rake任務使用路由助手它使用此代碼:在Rake任務
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
我需要在「register_url」來傳遞郵件程序爲了使鏈接顯示在電子郵件中,但由於這是從rake任務運行而不是從請求運行,因此它無法訪問輔助方法。達到這個目標的最好方法是什麼?