Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Determine the correct template_root for deeply nested components. Clo…

…ses #2841.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4474 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit bbc1351344dd47e88a0251ca9a0f6301301b1202 1 parent d19e464
@jeremy jeremy authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Determine the correct template_root for deeply nested components. #2841 [s.brink@web.de]
+
* Fix that routes with *path segments in the recall can generate URLs. [Rick]
* Fix strip_links so that it doesn't hang on multiline <acronym> tags [Jamis Buck]
View
4 actionpack/lib/action_controller/components.rb
@@ -75,8 +75,8 @@ def process_with_components(request, response, parent_controller = nil) #:nodoc:
# will also use /code/weblog/components as template root
# and find templates in /code/weblog/components/admin/parties/users/
def uses_component_template_root
- path_of_calling_controller = File.dirname(caller[0].split(/:\d+:/).first)
- path_of_controller_root = path_of_calling_controller.sub(/#{controller_path.split("/")[0..-2]}$/, "") # " (for ruby-mode)
+ path_of_calling_controller = File.dirname(caller[0].split(/:\d+:/, 2).first)
+ path_of_controller_root = path_of_calling_controller.sub(/#{Regexp.escape(File.dirname(controller_path))}$/, "")
self.template_root = path_of_controller_root
end
View
21 actionpack/test/controller/components_test.rb
@@ -126,4 +126,23 @@ def test_component_as_string_redirect_renders_redirecte_action
assert_equal "Lady of the House, speaking", @response.body
end
-end
+end
+
+module A
+ module B
+ module C
+ class NestedController < ActionController::Base
+ # Stub for uses_component_template_root
+ def self.caller
+ ['./test/fixtures/a/b/c/nested_controller.rb']
+ end
+ end
+ end
+ end
+end
+
+class UsesComponentTemplateRootTest < Test::Unit::TestCase
+ def test_uses_component_template_root
+ assert_equal './test/fixtures/', A::B::C::NestedController.uses_component_template_root
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.