0

我正在開發一個應用程序,它應該向iOS設備發送推送通知。我正在使用apn_on_rails gem。一切工作正常軌道控制檯。然而,當我運行服務器,我得到了所有的基本觀點方法,例如content_forform_tag等未定義的方法錯誤:apn_on_rails在rails 2.3.8上打破視圖助手?

當我從我development.rb出來,觀點重新工作require 'apn_on_rails',但當然不推送通知。

下面是一個例子跟蹤:

Processing DashboardController#index (for 127.0.0.1 at 2011-02-27 13:55:59) [GET] 
User Load (0.2ms) SELECT * FROM "users" WHERE ("users"."id" = 1) 
CACHE (0.0ms) SELECT * FROM "users" WHERE ("users"."id" = 1) 
Rendering template within layouts/dashboard 
Rendering dashboard/index 

ActionView::TemplateError (undefined method `content_for' for #<ActionView::Base:0x103343970>) on line #1 of app/views/dashboard/index.html.erb: 
1: <% content_for :header do %> 
2: <%= render :partial => "header", :locals => {:title => "Dashboard"} %> 
3: <% end %> 


app/views/dashboard/index.html.erb:1 
app/controllers/dashboard_controller.rb:6:in `index' 

Rendered rescues/_trace (28.5ms) 


Processing ApplicationController#index (for 127.0.0.1 at 2011-02-27 13:55:59) [GET] 

ActionView::TemplateError (undefined method `debug' for #<ActionView::Base:0x103343970>) in /Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb: 



Rendered rescues/_trace (24.0ms) 
/!\ FAILSAFE /!\ Sun Feb 27 13:55:59 +0100 2011 
Status: 500 Internal Server Error 

ActionView::TemplateError (undefined method `debug' for #<ActionView::Base:0x1031eaad8>) in /Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb: 




In /library/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb 

感謝您的幫助......

+0

我想知道那個development.rb文件看起來像什麼..? – conny 2011-02-27 18:53:33

回答

1

這一點並不明顯,你是否打電話config.gem 'apn_on_rails' - 它像你require聽起來比較:荷蘭國際集團的庫,可能是你在這一點上不應該做的事情:環境設置的重點。

在您的環境設置(即development.rb)中有config.gem事物,但最終require會在稍後發生( - >在控制器/模型/幫助器中)。

+0

謝謝conny。添加'config.gem'並將需求移動到控制器確實解決了問題。 – 2011-02-27 21:46:51