2012-01-13 15 views
0

ユーザーが空白を入力した後、私のメールに情報を形成したい。しかし、ユーザーのモデル属性を自分のメールアドレスにHTML形式で送ることはできません。Rails 3 ActionMailerモデル属性

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

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

とdemand_call.html.erbはその

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

のようですが、エラーが、私はそれを解決する方法を

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

のですか?

答えて

0

あなたのアドバイスのおかげ:)が働いているビュー

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

内でそれを使用することができますよりも、あなたは方法

class DemandMailer < ActionMailer::Base default from: "[email protected]" def demand_call(demand) @demand = demand mail(:to => "[email protected]" , :subject => "user registered") end end 

内のインスタンス変数を定義する必要があります。 – ndrx42

関連する問題