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