未定义的方法“错误”对于真:TrueClass
我正在使用 Spree,并设置 spree_easy_contact 扩展。
当我发送电子邮件时,它会正确发送,并将其正确保存到数据库,但我被重定向到错误屏幕:
NoMethodError in ContactsController#create
undefined method `error' for true:TrueClass
它没有给出任何关于可能出错的地方的提示。有谁知道这个错误是由什么引起的?
这是我的日志中留下的唯一内容:
NoMethodError (undefined method `error' for true:TrueClass):
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.7ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4980.8ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (5123.9ms)
这是来自 Gem 的 contact_controller :
def create
@contact = Contact.new(params[:contact] || {})
respond_to do |format|
if @contact.valid? && @contact.save
ContactMailer.message_email(@contact).deliver
format.html { redirect_to(root_path, :notice => t("message_sended")) }
else
format.html { render :action => "new" }
end
end
end
I'm using Spree, and setting up the spree_easy_contact extension.
When I send an email, it sends correctly, and saves it to the database correctly, but I'm redirected to an error screen :
NoMethodError in ContactsController#create
undefined method `error' for true:TrueClass
It doesn't give any hints as to where this might be erring. Does anyone know what this error is caused by?
Here is the only thing left in my log :
NoMethodError (undefined method `error' for true:TrueClass):
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.7ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4980.8ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (5123.9ms)
This is from the Gem's contact_controller :
def create
@contact = Contact.new(params[:contact] || {})
respond_to do |format|
if @contact.valid? && @contact.save
ContactMailer.message_email(@contact).deliver
format.html { redirect_to(root_path, :notice => t("message_sended")) }
else
format.html { render :action => "new" }
end
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来问题出在这一行:
format.html {redirect_to(root_path, :notice => t("message_send")) }
您可以增加日志记录以查看此错误发生在哪里吗?
也许你可以设置 config.log_level = :debug 来获取更多信息。
It seems that the problem is in this line:
format.html { redirect_to(root_path, :notice => t("message_sended")) }
Can you increase logging to see where this error is happening?
Maybe you can set config.log_level = :debug to get more information.