2011-02-11 139 views
3

我正在使用Spree,並設置了spree_easy_contact擴展。未定義的方法`錯誤'爲true:TrueClass

當我發送一封電子郵件,它正確地發送,並正確保存到數據庫中,但我重定向到一個錯誤的屏幕:

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) 

這是從創業板公司的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

看來這個問題是在這一行:

格式.html {redirect_to(root_path,:notice => t(「message_sended」))}

你可以增加日誌記錄來查看發生這個錯誤的位置嗎?

也許你可以設置config.log_level =:debug來獲取更多信息。

+0

如果它在0那麼它是:調試,對吧? – Trip 2011-02-13 19:38:33