1
使用rails邮件程序时出现问题,rails无法在我的邮件程序中找到方法,并声称在邮件程序类中找不到该模板。Rails 4.2.5无法找到模板
因此测试错误:
class ContactMailer < ApplicationMailer
def contact_email(email, name, subject, comment)
@email = email
@name = name
@subject = subject
@comment = comment
mail cc: @email
end
end
但是:
class ContactMailerTest < ActionMailer::TestCase
test "should return contact email" do
mail = ContactMailer.contact_email("[email protected]", "Example",
"SomeExample", @comment = "Hello")
assert_equal ['[email protected]'], mail.to
assert_equal ['[email protected]'], mail.from
end
end
正如你所看到的,这是调用ContactMailer类,并在其中
ContactMailer类中的方法CONTACT_EMAIL测试失败,声称它无法找到模板,这也是不可重现的IE我有另一个项目具有相同的代码,但没有问题出现,是否有解决方案是什么?
Returned Error:
1) Error:
ContactMailerTest#test_should_return_contact_email:
ActionView::MissingTemplate: Missing template contact_mailer/contact_email with "mailer". Searched in:
* "contact_mailer"
app/mailers/contact_mailer.rb:9:in `contact_email'
test/mailers/contact_mailer_test.rb:8:in `block in <class:ContactMailerTest>'
3 runs, 2 assertions, 0 failures, 1 errors, 0 skips
我在Windows上运行的RubyMine,红宝石版本2.2.3,4.2.5轨道
谢谢!
确切的问题,已经定义.html.haml.erb,没有找到模板 – kxdan
@kxdan,你可能想标记rlarcombe为接受的答案 – amree