未定义的方法“错误”对于真:TrueClass

发布于 2024-10-17 03:47:54 字数 1189 浏览 7 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠我空喜 2024-10-24 03:47:54

看来问题出在这一行:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文