Permalink
Browse files

Ensure that env is always available in controllers

  • Loading branch information...
1 parent b53efd2 commit 233be6572c96087192885924c6658a15d01a2a1b @drogus drogus committed Jul 14, 2010
Showing with 6 additions and 2 deletions.
  1. +5 −1 actionpack/lib/action_controller/metal.rb
  2. +1 −1 actionpack/lib/action_controller/metal/url_for.rb
@@ -52,7 +52,11 @@ def build(action, app=nil, &block)
class Metal < AbstractController::Base
abstract!
- attr_internal :env
+ attr_internal_writer :env
+
+ def env
+ @_env ||= {}
+ end
# Returns the last part of the controller's name, underscored, without the ending
# <tt>Controller</tt>. For instance, PostsController returns <tt>posts</tt>.
@@ -6,7 +6,7 @@ module UrlFor
def url_options
options = {}
- if respond_to?(:env) && env && _routes.equal?(env["action_dispatch.routes"])
+ if _routes.equal?(env["action_dispatch.routes"])
options[:script_name] = request.script_name
end

0 comments on commit 233be65

Please sign in to comment.