2016-04-15 7 views
0

生産時にメールでメールを送信しようとすると頭が痛いです(heroku)。 heroku logsを実行しているとき、私は、次を得る:プロダクション(heroku)でActionView :: MissingTemplateを解決しようとしています

2016-04-15T18:20:47.117490+00:00 app[web.1]: ClienteMailer#boas_vindas: processed outbound mail in 5.8ms 
2016-04-15T18:20:47.118282+00:00 app[web.1]: (0.7ms) ROLLBACK 
2016-04-15T18:20:47.117474+00:00 app[web.1]: 
2016-04-15T18:20:47.118705+00:00 app[web.1]: Completed 500 Internal Server Error in 31ms (ActiveRecord: 6.5ms) 
2016-04-15T18:20:47.120623+00:00 app[web.1]: ActionView::MissingTemplate (Missing template layouts/mailer with {:locale=>[:"pt-BR"], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: 
2016-04-15T18:20:47.120613+00:00 app[web.1]: 
2016-04-15T18:20:47.120624+00:00 app[web.1]: * "/app/app/views" 
2016-04-15T18:20:47.120625+00:00 app[web.1]: app/mailers/cliente_mailer.rb:6:in `block (2 levels) in boas_vindas' 
2016-04-15T18:20:47.120625+00:00 app[web.1]:): 
2016-04-15T18:20:47.120627+00:00 app[web.1]: app/models/cadastro.rb:6:in `envia_email_boasvindas' 
2016-04-15T18:20:47.120626+00:00 app[web.1]: app/mailers/cliente_mailer.rb:5:in `boas_vindas' 
2016-04-15T18:20:47.120626+00:00 app[web.1]: app/mailers/cliente_mailer.rb:6:in `block in boas_vindas' 
2016-04-15T18:20:47.120627+00:00 app[web.1]: app/controllers/cadastros_controller.rb:18:in `create' 

テンプレートに問題があるようですが、メーラーのテンプレートは、ディレクトリlayouts/mailer.html.erbです。

メーラー/ application_mailer.rb

class ApplicationMailer < ActionMailer::Base 
     default from: "Example <[email protected]>" 
     layout 'mailer' 
    end 

メーラー/ cliente_mailer.rb

class ClienteMailer < ApplicationMailer 
    def boas_vindas cliente 
     @cliente = cliente 
     mail(:to => @cliente.email, :subject => 'Example.') do |format| 
      format.html { render 'boas_vindas' } 
     end 
    end 
end 

モデル/ cadastro.rb

. 
. 
. 
after_create :envia_email_boasvindas 
def envia_email_boasvindas 
    ClienteMailer.boas_vindas(self).deliver 
end 
. 
. 
. 

:以下

は、コードactionmailerのありますデベロッパーすべて正常に動作します。何が忘れているのか、忘れているのか?

+0

:私は変更を加え ' <%= yield %> ' – Micael

答えて

0

これが問題であるかどうかわかりませんが、メーラーでフォーマットを指定する必要はありません。ちょうどそれをしてください:

class ClienteMailer < ApplicationMailer 
    def boas_vindas cliente 
     @cliente = cliente 
     mail(:to => @cliente.email, :subject => 'Example.') 
    end 
end 

これは私が通常見ることができるものとの唯一の違いです。 mailer.html.erb` `以内

+0

は、残念ながら、私はHerokuの中に同じエラーログを取得しておきます。 – Micael

+0

私は 'application_controller.rb'の' layout 'mailer'を削除することで問題を解決することができました。 'mailer.html.erb'レイアウトではなく、' cliente_mailer.rb'の 'boas_vindas.html.erb'を使っているようです。奇妙なことは、これが生産でのみ起こる、環境の設定でしょうか? – Micael

関連する問題