diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-07-14 09:17:24 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:06 +0200 |
commit | 233be6572c96087192885924c6658a15d01a2a1b (patch) | |
tree | bca0c65664431eac01276ef60bd5a95d58495290 /actionpack/lib/action_controller | |
parent | b53efd21059b9d829a6617fb5b2dd86754684c60 (diff) | |
download | rails-233be6572c96087192885924c6658a15d01a2a1b.tar.gz rails-233be6572c96087192885924c6658a15d01a2a1b.tar.bz2 rails-233be6572c96087192885924c6658a15d01a2a1b.zip |
Ensure that env is always available in controllers
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/url_for.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 96ac138ba3..def28a0054 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -52,7 +52,11 @@ module ActionController 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>. diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index c1f1be3bef..e7eb7485c4 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -6,7 +6,7 @@ module ActionController 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 |