undefined方法`error'表示true:TrueClass

时间:2011-02-11 15:18:10

标签: ruby-on-rails contact spree

我正在使用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

1 个答案:

答案 0 :(得分:1)

似乎问题在于这一行:

format.html {redirect_to(root_path,:notice => t(“message_sended”))}

您是否可以增加日志记录以查看此错误发生的位置?

也许你可以设置config.log_level =:debug来获取更多信息。