<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -124,6 +124,8 @@ module Ardes#:nodoc:
     # file.  This enables +render_parent+ to know which to file render.
     #
     module ActionView
+      extend ActiveSupport::Memoizable
+      
       def self.included(base)# :nodoc:
         base.class_eval do
           alias_method_chain :render, :inherit_views
@@ -131,7 +133,7 @@ module Ardes#:nodoc:
           alias_method :_orig_pick_template, :_pick_template
           
           def _pick_template(template_path)
-            _orig_pick_template(template_path)
+            _pick_inherited_template_for_controller(template_path, controller)
           end
         end
       end
@@ -139,16 +141,12 @@ module Ardes#:nodoc:
       # Renders the parent template for the current template
       # takes normal rendering options (:layout, :locals, etc)
       def render_parent(options = {})
-        #raise ArgumentError, 'render_parent requires that controller inherit_views' unless (controller.inherit_views? rescue false)
-        #
-        #if @current_render
-        #  if @current_render[:file] &amp;&amp; (file = _pick_template(@current_render[:file], include_self = false))
-        #    return render(options.merge(:file =&gt; file))
-        #  elsif @current_render[:partial] &amp;&amp; (partial = _pick_template(_pick_partial_template(@current_render[:partial]), include_self = false))
-        #    return render(options.merge(:partial =&gt; partial))
-        #  end
-        #end
-        #raise InheritedFileNotFound, &quot;no parent for #{@current_render.inspect} found&quot;
+        raise ArgumentError, 'render_parent requires that controller inherit_views' unless (controller.inherit_views? rescue false)
+        
+        if @current_render &amp;&amp; @current_render[:file] &amp;&amp; (file = _pick_inherited_template(@current_render[:file], controller.inherit_view_paths))
+          return render(options.merge(:file =&gt; file))
+        end
+        raise InheritedFileNotFound, &quot;no parent for #{@current_render[:file]} found&quot;
       end
 
       # Find an inherited template path prior to rendering, if appropriate.
@@ -160,10 +158,37 @@ module Ardes#:nodoc:
     
       # Find an inherited template path for a controller context
       def inherited_template_path(template_path, controller_class = controller.class)
-        #_pick_template(template_path, true, controller_class.inherit_view_paths)
+        _pick_inherited_template_for_controller(template_path, controller).to_s
       end
     
     private
+      def _pick_inherited_template_for_controller(template_path, controller)
+        _orig_pick_template(template_path)
+      rescue ::ActionView::MissingTemplate
+        if (controller.inherit_views? rescue false)
+          _pick_inherited_template(template_path, controller.inherit_view_paths)
+        end
+      end  
+      
+      def _pick_inherited_template(template_path, inherit_view_paths)
+        starting_path = inherit_view_paths.detect {|p| template_path =~ /^#{p}\//}
+        
+        if starting_path 
+          inherit_paths_above_starting_path = inherit_view_paths.slice(inherit_view_paths.index(starting_path)+1..-1)
+          
+          inherit_paths_above_starting_path.each do |path|
+            inherited_template = begin
+              _orig_pick_template(template_path.sub(/^#{starting_path}/, path))
+            rescue ::ActionView::MissingTemplate
+              nil
+            end
+            
+            return inherited_template if inherited_template
+          end
+        end
+      end
+      memoize :_pick_inherited_template
+      
       def _with_current_render_of(options, &amp;block)
         orig, @current_render = @current_render, options
         yield</diff>
      <filename>lib/ardes/inherit_views.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,10 +40,8 @@ describe AController, &quot; &lt; TestController; inherit_views&quot; do
     end
   
     it &quot;GET :inherited_template_path should render its contents&quot; do
-      pending do
-        get :inherited_template_path
-        response.body.should == 'b/in_ab.html.erb'
-      end
+      get :inherited_template_path
+      response.body.should == 'b/in_ab.html.erb'
     end
   end
 end
\ No newline at end of file</diff>
      <filename>spec/controllers/a_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,10 +40,8 @@ describe BController, &quot; &lt; TestController; inherit_views 'a'&quot; do
     end
 
     it &quot;GET :render_parent should render a/render_parent inside b/render_parent&quot; do
-      pending do 
-        get :render_parent
-        response.body.should == &quot;b:render_parent(a:render_parent)&quot;
-      end
+      get :render_parent
+      response.body.should == &quot;b:render_parent(a:render_parent)&quot;
     end
   
     it &quot;GET :bad_render_parent should raise ActionView::TemplateError as there is no parent to render&quot; do</diff>
      <filename>spec/controllers/b_controller_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>32f6e24e8e0b83ca40a30262d257556adc9b3609</id>
    </parent>
  </parents>
  <author>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </author>
  <url>http://github.com/ianwhite/inherit_views/commit/ce7bb6baa4aca976a9a726c4f052cdd416460b37</url>
  <id>ce7bb6baa4aca976a9a726c4f052cdd416460b37</id>
  <committed-date>2008-09-20T20:44:27-07:00</committed-date>
  <authored-date>2008-09-20T20:44:27-07:00</authored-date>
  <message>All specs passing except some to do with render parent</message>
  <tree>ef8b35cb8ec3005ace5cac3d5055e846031eacd7</tree>
  <committer>
    <name>Ian White</name>
    <email>ian.w.white@gmail.com</email>
  </committer>
</commit>
