动作管理器没什么问题

时间:2011-04-11 11:58:59

标签: ruby-on-rails

我的项目中的最后一个问题。

我的动作邮件

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

1 个答案:

答案 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