apn_on_rails 破坏了 Rails 2.3.8 上的视图助手?
我正在开发一个 Rails 应用程序,它应该向 iOS 设备发送推送通知。我正在使用 apn_on_rails gem。 Rails 控制台中一切正常。但是,当我运行服务器时,所有基本视图方法(例如 content_for
或 form_tag
等)都会出现未定义的方法错误:
当我采取 require 'apn_on_rails'< /code> 从我的
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
感谢您的帮助...
I am developing a rails application which should send push notifications to iOS devices. I am using apn_on_rails gem. Everything works fine in the rails console. However when I run the server, I get undefined method errors for all the basic view methods such as content_for
or form_tag
etc:
When I take require 'apn_on_rails'
from my development.rb
out, the views work again, but of course without push notifications.
Here is an example trace:
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
Thanks for any help...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前尚不清楚您是否调用
config.gem 'apn_on_rails'
- 听起来更像是您在require
:ing 库,这可能是您不应该做的事情point:环境设置点。在您的环境设置中包含 config.gem 内容(即development.rb),但稍后会发生最终的require(-> 在相关的控制器/模型/帮助程序中)。
It is not evident whether you call
config.gem 'apn_on_rails'
- it sounds more like you arerequire
:ing the library, which probably is something you should not do at this point: the point of environment setup.Have the config.gem things in your environment setup (i.e. development.rb), but make eventual
require
s happen later (->in the controller / model / helper in question).