当使用Rails 3.2本地开发,我定期会收到以下错误消息在本地突破:的Rails 3.2:观点路由佣工后其他错误
In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers
此错误是从我的观点非常简单的link_to
调用抛出,这些路由帮助程序会自动包含在内,并且不应该抛出这样的错误。我不认为错误是发生在那里说,但我会后一个例子错误转储的完整性的缘故:
Completed 500 Internal Server Error in 233ms
ActionView::Template::Error (In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers):
1: <%= form_tag products_path do %>
app/views/layouts/_search_banner.html.erb:1:in `_app_views_layouts__search_banner_html_erb___3528929561490713150_70155778060240'
app/views/pages/new.html.erb:1:in `_app_views_pages_new_html_erb__29715639072237790_70155789748980'
出现在它之前,我可以正常查看我的所有网页的;在出现之后,刚刚加载成功的相同页面会失败,并显示相同的错误。一旦出现错误,修复它的唯一方法是退出并重新启动我的本地Rails服务器。只要我重新启动服务器,错误消失,一切恢复正常。
此外,这个错误只出现在我的电脑本地 - 代码部署在Heroku上,这个错误在部署的几个月内没有出现,并且没有其他团队成员在相同的代码上运行时发现错误。 编辑:其他团队成员操作相同的代码做看到相同的错误。
虽然这个错误有时会从无处蹦出,没有明显的原因,但我注意到了一些趋势。它经常出现在不同的错误之后。当导轨服务器闲置一段时间而没有加载任何页面时,它也更有可能出现。
编辑:更多信息 Rails的版本:3.2.13 红宝石版本:2.0.0
完整的堆栈跟踪,可以发现here
我通过编写代码来抛出取得的错误操作中发生错误,向该操作发送请求,然后尝试访问应用程序中的任何其他页面。有趣的是,我试图使用的第一个错误是被零除,而不会产生错误。接下来,我为Array []错误创建了一个未定义的方法,这导致了这里描述的方法。
编辑:弃用警告为Rails 2.3风格的插件 当我部署到Heroku上,我得到以下错误:
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins!
Support for these plugins will be removed in Rails 4.0.
Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb.
See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released.
(called from <top (required)> at /tmp/build_175439d1-f385-43bd-bf52-ebcae817e70b/Rakefile:7)
此错误是扔在我的Rake文件就行了MyApp::Application.load_tasks
。我的vendor/plugin
目录中没有任何文件。
另外,不像[其他类似的SO帖子](http://stackoverflow.com/questions/17553326/call-to-expire-fragment-raises-to-use-url-对于任您必须-包括路由,helpe?rq = 1),我最近还没有切换Rails版本。 – hunteros
您是否尝试重新安装ruby和rails,因为这种异常只发生在您的本地环境中?什么是红宝石的版本?你能发布完整的跟踪吗?为了您的参考,这个异常提出在这里:https://github.com/rails/rails/blob/e20dd73df42d63b206d221e2258cc6dc7b1e6068/actionpack/lib/abstract_controller/url_for.rb – peresleguine
@peresleguine我添加了红宝石版本和完整跟踪的问题。 – hunteros