English 中文(简体)
铁路3号行动邮件模型
原标题:Rails 3 ActionMailer Model Attribute

在用户填充灯后,我想向我的邮件提供信息。 但是,我可以以超文本格式将用户模型属性寄给我的邮件地址。

class DemandMailer < ActionMailer::Base
  default from: "[email protected]"

  def demand_call(demand)
      mail(:to => "[email protected]" , :subject => "user registered") 
  end
end

和需求——召唤.html.erb类似

the user name is <%= @demand.name %> 

但错误

ActionView::Template::Error (undefined method `name  for nil:NilClass):

我如何解决这一问题?

最佳回答

你们应当界定在方法上的差异

  class DemandMailer < ActionMailer::Base
    default from: "[email protected]"

    def demand_call(demand)
      @demand = demand
      mail(:to => "[email protected]" , :subject => "user registered") 
    end
  end

than can use it inside view

the user name is <%= @demand.name %>
问题回答

暂无回答




相关问题
How to use send an email with accents using actionmailer

My environment.rb is like this: ActionMailer::Base.default_charset = "iso-8859-1" which should be enough for accents, but here is how the message s subject is being sent: Convite para ...

Setting ActionMailer template_root at runtime

Is it possible to set template_root for ActionMailer at runtime? I seem to be able to do this in development mode by using: ActionMailer::Base.template_root = my_view_path if File.exists (File.join(...

Managing critical errors: logging & email [closed]

What s the best way to send quick one-liner e-mails to an administrative address in Rails? I am using the Rails Logger to keep track of nasty problems in my application. One of my controllers is ...

email sent status from rails or actionmailer

I am developing a test application and running the whole thing on my work pc. I am using my corporate mail server to send mails. It works fine normally. I was wondering how to handle any conditions ...

Rails ActionMailer problems on Mac

I ve been working on learning to use Rails the last couple days and I ve run into something that I haven t been able to solve with Google. So I m just creating a basic contact form that sends an ...

热门标签