【问题标题】:apn_on_rails breaking view helpers on rails 2.3.8?apn_on_rails 打破 rails 2.3.8 上的视图助手?
【发布时间】:2011-07-05 05:42:39
【问题描述】:

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

当我从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

感谢您的帮助...

【问题讨论】:

  • 我想知道那个 development.rb 文件长什么样..?

标签: ruby-on-rails rubygems apple-push-notifications actionview


【解决方案1】:

不清楚你是否调用config.gem 'apn_on_rails' - 听起来你更像是require: 在调用库,这可能是你此时不应该做的事情:环境设置点。

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

【讨论】:

  • 谢谢康妮。添加config.gem 并将需求移至控制器确实解决了问题。
猜你喜欢
  • 2011-07-16
  • 1970-01-01
  • 2011-05-26
  • 2015-11-08
  • 2011-06-27
  • 1970-01-01
  • 2020-12-20
  • 2011-07-07
  • 2016-09-29
相关资源
最近更新 更多