Rails 3.2: Routing helpers in views break locally after other error

When developing locally using Rails 3.2, I periodically receive the following error message:

In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers

This error is thrown from my views in a very simple link_to call, where these routing helpers are automatically included and should not throw such an error. I don't think the error is occurring where it says, but I'll post an example error dump for completeness' sake:

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'

Before it appears, I am able to properly view all of my pages; after it appears, the same pages that had just loaded successfully fail with that same error. Once the error appears, the only way to fix it is to exit and restart my local rails server. As soon as I restart my server the error disappears and everything goes back to working normally.

Also, this error only appears locally on my computer - the code is deployed on Heroku and this error has not appeared in months of deployment, and no other team members operating on the same code have seen the error. EDIT: other team members operating on the same code do see the same error.

Although this error sometimes pops up out of nowhere with no apparent cause, there are a couple of trends I have noticed. It frequently appears immediately after a different error. It also is more likely to appear when the rails server has been idle for some time without loading any pages.

EDIT: More Information Rails version: 3.2.13 Ruby version: 2.0.0

The full stack trace can be found here

I achieved the error by writing code to throw an error in an action, sending a request to that action, then attempting to access any other page in the application. Interestingly, the first error that I attempted to use was a division by zero, which did not create the error. Next, I created a Undefined Method for Array[] error, which resulted in the one described here.

EDIT: Deprecation Warning for Rails 2.3-style plugins When I deploy to Heroku, I get the following error:

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)

This error is thrown in my Rakefile on the line MyApp::Application.load_tasks. I do not have any files in my vendor/plugin directory.


as far as i can see it's an issue with your rails version. see the comments on this resque issue: https://github.com/rails/rails/issues/11782#issuecomment-22222166


Try replacing this

<a href="<%= root_path %>" class="nav-link"><%= image_tag "image.svg", onerror: "this.src='image.png'" %></a>

with this

<%= link_to(image_tag("image.svg", onerror: "this.src='image.png'"), root_path, class: "nav-link") %>

Need Your Help

UIKit: Initial first responder?

ios iphone uikit first-responder

When an app launches, what is the initial first responder?