aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-10-03 05:47:41 +0000
committerRick Olson <technoweenie@gmail.com>2007-10-03 05:47:41 +0000
commit904df818d61b695a5f9508864137d13fffa22d15 (patch)
tree0464c6494e7dd570d9e7b0580a2305def4832d40 /actionpack/lib
parentb4ec9904c6f34331bbe32a304acf4b43e43a4f18 (diff)
downloadrails-904df818d61b695a5f9508864137d13fffa22d15.tar.gz
rails-904df818d61b695a5f9508864137d13fffa22d15.tar.bz2
rails-904df818d61b695a5f9508864137d13fffa22d15.zip
Move ActionController::Routing.optimise_named_routes to ActionController::Base.optimise_named_routes. Now you can set it in the config.
ActionController::Routing::DynamicSegment#interpolation_chunk should call #to_s on all values before calling URI.escape. [Rick] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7724 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-xactionpack/lib/action_controller/base.rb7
-rw-r--r--actionpack/lib/action_controller/integration.rb2
-rw-r--r--actionpack/lib/action_controller/routing.rb19
3 files changed, 14 insertions, 14 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 74d0a6c09a..91ca05347d 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -329,7 +329,12 @@ module ActionController #:nodoc:
# Sets the token parameter name for RequestForgery. Calling #protect_from_forgery sets it to :authenticity_token by default
cattr_accessor :request_forgery_protection_token
-
+
+ # Indicates whether or not optimise the generated named
+ # route helper methods
+ cattr_accessor :optimise_named_routes
+ self.optimise_named_routes = true
+
# Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
class_inheritable_accessor :allow_forgery_protection
self.allow_forgery_protection = true
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index c981c56e01..bde4bb5776 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -76,7 +76,7 @@ module ActionController
# install the named routes in this session instance.
# But we have to disable the optimisation code so that we can
# generate routes without @request being initialized
- Routing.optimise_named_routes=false
+ Base.optimise_named_routes=false
Routing::Routes.reload!
klass = class<<self; self; end
Routing::Routes.install_helpers(klass)
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 01615e57e7..7442adbb39 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -256,11 +256,6 @@ module ActionController
mattr_accessor :controller_paths
self.controller_paths = []
- # Indicates whether or not optimise the generated named
- # route helper methods
- mattr_accessor :optimise_named_routes
- self.optimise_named_routes = true
-
# A helper module to hold URL related helpers.
module Helpers
include PolymorphicRoutes
@@ -342,7 +337,7 @@ module ActionController
# Indicates whether the routes should be optimised with the string interpolation
# version of the named routes methods.
def optimise?
- @optimise && ActionController::Routing::optimise_named_routes
+ @optimise && ActionController::Base::optimise_named_routes
end
def segment_keys
@@ -718,8 +713,8 @@ module ActionController
s << "\n#{expiry_statement}"
end
- def interpolation_chunk(value_code = "#{local_name}.to_s")
- "\#{URI.escape(#{value_code}, ActionController::Routing::Segment::UNSAFE_PCHAR)}"
+ def interpolation_chunk(value_code = "#{local_name}")
+ "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::Segment::UNSAFE_PCHAR)}"
end
def string_structure(prior_segments)
@@ -776,8 +771,8 @@ module ActionController
end
# Don't URI.escape the controller name since it may contain slashes.
- def interpolation_chunk(value_code = "#{local_name}.to_s")
- "\#{#{value_code}}"
+ def interpolation_chunk(value_code = "#{local_name}")
+ "\#{#{value_code}.to_s}"
end
# Make sure controller names like Admin/Content are correctly normalized to
@@ -799,8 +794,8 @@ module ActionController
RESERVED_PCHAR = "#{Segment::RESERVED_PCHAR}/"
UNSAFE_PCHAR = Regexp.new("[^#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}]", false, 'N').freeze
- def interpolation_chunk(value_code = "#{local_name}.to_s")
- "\#{URI.escape(#{value_code}, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}"
+ def interpolation_chunk(value_code = "#{local_name}")
+ "\#{URI.escape(#{value_code}.to_s, ActionController::Routing::PathSegment::UNSAFE_PCHAR)}"
end
def default