我的项目中的最后一个问题。
我的动作邮件
class Notifier < ActionMailer::Base
def newgrants_notification(respondent)
recipients respondent.email
from "admiN@admin.com"
subject "Do it"
body (:user => user.name, :url_base => pass_this) #i think problem is this in url?
end
end
inquiry_model
def pass_this
return "http://localhost:3000/asnwer/index?user_id=#{self.id.to_i}&token=#{self.security_token}"
end
mailer_view中的
<p>Link to pass: <%= "#{@url_base}" %></p>
如何实现从model到action_mailer :: base的asnwer_form链接?现在链接是空的; [ 当我打开我的电子邮件时,我需要:有正确的user_id和令牌
的链接到我的路径 - security_token
表中的questions
user_id
表格中的users
答案 0 :(得分:1)
将查询实例传递给通知模型。并像这样访问它!
class Notifier < ActionMailer::Base
def newgrants_notification(respondent,inquiry_instance)
recipients respondent.email
from "admiN@admin.com"
subject "Do it"
body (:user => user.name, :url_base => inquiry_instance.pass_this) #i think problem is this in url?
end
end