0

我正在开发一个应该向 iOS 设备发送推送通知的 Rails 应用程序。我正在使用 apn_on_rails gem。在 Rails 控制台中一切正常。但是,当我运行服务器时,我得到所有基本视图方法的未定义方法错误,例如content_fororform_tag等​​:

当我require 'apn_on_rails'development.rb外面拿出来时,视图再次起作用,但当然没有推送通知。

这是一个示例跟踪:

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

谢谢你的帮助...

4

1 回答 1

1

您是否打电话并不明显config.gem 'apn_on_rails'- 听起来更像是在require:ing 库,这可能是您此时不应该做的事情:环境设置点。

在您的环境设置(即 development.rb)中有 config.gem 的东西,但让最终require的 s 稍后发生(-> 在有问题的控制器/模型/助手中)。

于 2011-02-27T18:52:54.547 回答