aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-05-09 11:48:33 +0100
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-16 21:44:24 -0200
commit0c7a236f30c12c981cf376d08ac01e423308533d (patch)
treec71c54af80f823655d4dd3c456136bfec263341c /actionpack/lib/action_dispatch
parent09c4dfa06bcf049ada7b127f70d3c5eb5e9cd91d (diff)
downloadrails-0c7a236f30c12c981cf376d08ac01e423308533d.tar.gz
rails-0c7a236f30c12c981cf376d08ac01e423308533d.tar.bz2
rails-0c7a236f30c12c981cf376d08ac01e423308533d.zip
Refactor Generator class to not rely on in-place editing the controller
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 966f5bf157..8168bd4fcc 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -442,12 +442,12 @@ module ActionDispatch
normalize_options!
normalize_controller_action_id!
use_relative_controller!
- controller.sub!(%r{^/}, '') if controller
+ normalize_controller!
handle_nil_action!
end
def controller
- @controller ||= @options[:controller]
+ @options[:controller]
end
def current_controller
@@ -476,11 +476,11 @@ module ActionDispatch
if options[:controller]
options[:action] ||= 'index'
- options[:controller] = options[:controller].to_s.dup
+ options[:controller] = options[:controller].to_s
end
if options[:action]
- options[:action] = options[:action].to_s.dup
+ options[:action] = options[:action].to_s
end
end
@@ -504,10 +504,15 @@ module ActionDispatch
old_parts = current_controller.split('/')
size = controller.count("/") + 1
parts = old_parts[0...-size] << controller
- @controller = @options[:controller] = parts.join("/")
+ @options[:controller] = parts.join("/")
end
end
+ # Remove leading slashes from controllers
+ def normalize_controller!
+ @options[:controller] = controller.sub(%r{^/}, '') if controller
+ end
+
# This handles the case of :action => nil being explicitly passed.
# It is identical to :action => "index"
def handle_nil_action!