From e03e1fdbc85bc05536a2770817c31b08d4f6be51 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 26 Dec 2010 23:56:09 -0800 Subject: Speed up template inheritance and remove template inheritance option --- actionpack/lib/abstract_controller/rendering.rb | 33 +++++++++++----------- actionpack/test/controller/new_base/render_test.rb | 12 -------- 2 files changed, 17 insertions(+), 28 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 01dd4ffeb1..9b912ea988 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -60,6 +60,20 @@ module AbstractController end end end + + def parent_prefixes + @parent_prefixes ||= begin + parent_controller = superclass + prefixes = [] + + until parent_controller.abstract? + prefixes << parent_controller.controller_path + parent_controller = parent_controller.superclass + end + + prefixes + end + end end attr_writer :view_context_class @@ -116,18 +130,10 @@ module AbstractController # The prefixes used in render "foo" shortcuts. def _prefixes - prefixes = [controller_path] - - if template_inheritance? - parent_controller = self.class.superclass - - until parent_controller.abstract? - prefixes << parent_controller.controller_path - parent_controller = parent_controller.superclass - end + @_prefixes ||= begin + parent_prefixes = self.class.parent_prefixes + parent_prefixes.dup.unshift(controller_path) end - - prefixes end private @@ -176,10 +182,5 @@ module AbstractController def _process_options(options) end - - def template_inheritance? - # is there a better way to check for config option being set? - config.template_inheritance.nil? ? true : config.template_inheritance - end end end diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb index f5baa829b6..d6062bfa8c 100644 --- a/actionpack/test/controller/new_base/render_test.rb +++ b/actionpack/test/controller/new_base/render_test.rb @@ -53,10 +53,6 @@ module Render prepend_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_prepended.html.erb" => "child content") end - class ChildRenderWithoutInheritanceController < BlankRenderController - config.template_inheritance = false - end - class RenderTest < Rack::TestCase test "render with blank" do with_routing do |set| @@ -138,12 +134,4 @@ module Render assert_body "Hello world!" end end - - class TestNoViewInheritance < Rack::TestCase - test "Template from parent controller does not get picked if config.action_controller.template_inheritance = false" do - assert_raises(ActionView::MissingTemplate) do - get "/render/child_render_without_inheritance/index", {}, "action_dispatch.show_exceptions" => false - end - end - end end -- cgit v1.2.3